xref: /llvm-project/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp (revision cb08f4aa4467cf562b62e542725f5351c5482495)
1 // RUN: %clang_cc1 -fsyntax-only -std=c++2a -verify %s
2 
3 struct [[nodiscard]] S1 {}; // ok
4 struct [[nodiscard, nodiscard]] S2 {}; // ok
5 struct [[nodiscard("Wrong")]] S3 {};
6 
7 [[nodiscard]] int f();
8 enum [[nodiscard]] E {};
9 
10 namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only applies to Objective-C methods, enums, structs, unions, classes, functions, function pointers, and typedefs}}
11