libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

nodiscard_extensions.pass.cpp (980B)


      1 // -*- C++ -*-
      2 //===----------------------------------------------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 // Test that entities declared [[nodiscard]] as at extension by libc++, are
     12 // only actually declared such when _LIBCPP_ENABLE_NODISCARD is specified.
     13 
     14 // This test intentionally leaks memory, so it is unsupported under ASAN.
     15 // UNSUPPORTED: asan
     16 
     17 // All entities to which libc++ applies [[nodiscard]] as an extension should
     18 // be tested here and in nodiscard_extensions.fail.cpp. They should also
     19 // be listed in `UsingLibcxx.rst` in the documentation for the extension.
     20 
     21 #include <memory>
     22 
     23 #include "test_macros.h"
     24 
     25 int main() {
     26   {
     27     std::get_temporary_buffer<int>(1); // intentional memory leak.
     28   }
     29 }