• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
10 // #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
11 
12 // UNSUPPORTED: c++03
13 // UNSUPPORTED: (c++11 || c++14 || c++17) && !stdlib=libc++
14 
15 #include <__config>
16 
foo()17 _LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
18 
f()19 void f() {
20     foo(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
21 }
22