Clang Project

clang_source_code/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s
2
3struct [[nodiscard]] S1 {}; // ok
4struct [[nodiscard nodiscard]] S2 {}; // expected-error {{attribute 'nodiscard' cannot appear multiple times in an attribute specifier}}
5struct [[nodiscard("Wrong")]] S3 {}; // expected-error {{'nodiscard' cannot have an argument list}}
6
7[[nodiscard]] int f();
8enum [[nodiscard]] E {};
9
10namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only applies to Objective-C methods, enums, structs, unions, classes, functions, and function pointers}}
11