• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E -P %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
3 
4 #define C2x(x) x: __has_c_attribute(x)
5 
6 // CHECK: fallthrough: 201904L
7 C2x(fallthrough)
8 
9 // CHECK: __nodiscard__: 201904L
10 C2x(__nodiscard__)
11 
12 // CHECK: selectany: 0
13 C2x(selectany); // Known attribute not supported in C mode
14 
15 // CHECK: frobble: 0
16 C2x(frobble) // Unknown attribute
17 
18 // CHECK: frobble::frobble: 0
19 C2x(frobble::frobble) // Unknown vendor namespace
20 
21 // CHECK: clang::annotate: 1
22 C2x(clang::annotate)
23 
24 // CHECK: deprecated: 201904L
25 C2x(deprecated)
26 
27 // CHECK: maybe_unused: 201904L
28 C2x(maybe_unused)
29 
30 // CHECK: __gnu__::warn_unused_result: 201904L
31 C2x(__gnu__::warn_unused_result)
32 
33 // CHECK: gnu::__warn_unused_result__: 201904L
34 C2x(gnu::__warn_unused_result__)
35 
36 // We do somewhat support the __clang__ vendor namespace, but it is a
37 // predefined macro and thus we encourage users to use _Clang instead.
38 // Because of this, we do not support __has_c_attribute for that
39 // vendor namespace.
40 //
41 // Note, we can't use C2x here because it will expand __clang__ to 1
42 // too early.
43 // CHECK: 1::fallthrough: 0
44 __clang__::fallthrough: __has_c_attribute(__clang__::fallthrough)
45