xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/cxx11-attr-print.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
2*f4a2713aSLionel Sambuc //
3*f4a2713aSLionel Sambuc // CHECK: int x __attribute__((aligned(4)));
4*f4a2713aSLionel Sambuc int x __attribute__((aligned(4)));
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc // FIXME: Print this at a valid location for a __declspec attr.
7*f4a2713aSLionel Sambuc // CHECK: int y __declspec(align(4));
8*f4a2713aSLionel Sambuc __declspec(align(4)) int y;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // CHECK: int z {{\[}}[gnu::aligned(4)]];
11*f4a2713aSLionel Sambuc int z [[gnu::aligned(4)]];
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc // CHECK: __attribute__((deprecated("warning")));
14*f4a2713aSLionel Sambuc int a __attribute__((deprecated("warning")));
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
17*f4a2713aSLionel Sambuc int b [[gnu::deprecated("warning")]];
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc // CHECK: int cxx11_alignas alignas(4);
20*f4a2713aSLionel Sambuc alignas(4) int cxx11_alignas;
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // CHECK: int c11_alignas _Alignas(alignof(int));
23*f4a2713aSLionel Sambuc _Alignas(int) int c11_alignas;
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc // CHECK: void foo() __attribute__((const));
26*f4a2713aSLionel Sambuc void foo() __attribute__((const));
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // CHECK: void bar() __attribute__((__const));
29*f4a2713aSLionel Sambuc void bar() __attribute__((__const));
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // CHECK: int f1() __attribute__((warn_unused_result));
32*f4a2713aSLionel Sambuc int f1() __attribute__((warn_unused_result));
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc // CHECK: {{\[}}[clang::warn_unused_result]];
35*f4a2713aSLionel Sambuc int f2 [[clang::warn_unused_result]] ();
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc // CHECK: {{\[}}[gnu::warn_unused_result]];
38*f4a2713aSLionel Sambuc int f3 [[gnu::warn_unused_result]] ();
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc // FIXME: ast-print need to print C++11
41*f4a2713aSLionel Sambuc // attribute after function declare-id.
42*f4a2713aSLionel Sambuc // CHECK: {{\[}}[noreturn]];
43*f4a2713aSLionel Sambuc void f4 [[noreturn]] ();
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc // CHECK: __attribute__((gnu_inline));
46*f4a2713aSLionel Sambuc inline void f6() __attribute__((gnu_inline));
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc // CHECK: {{\[}}[gnu::gnu_inline]];
49*f4a2713aSLionel Sambuc inline void f7 [[gnu::gnu_inline]] ();
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc // arguments printing
52*f4a2713aSLionel Sambuc // CHECK: __attribute__((format(printf, 2, 3)));
53*f4a2713aSLionel Sambuc void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc // CHECK: int m __attribute__((aligned(4
56*f4a2713aSLionel Sambuc // CHECK: int n alignas(4
57*f4a2713aSLionel Sambuc // CHECK: static int f() __attribute__((pure))
58*f4a2713aSLionel Sambuc // CHECK: static int g() {{\[}}[gnu::pure]]
59*f4a2713aSLionel Sambuc template <typename T> struct S {
60*f4a2713aSLionel Sambuc   __attribute__((aligned(4))) int m;
61*f4a2713aSLionel Sambuc   alignas(4) int n;
fS62*f4a2713aSLionel Sambuc   __attribute__((pure)) static int f() {
63*f4a2713aSLionel Sambuc     return 0;
64*f4a2713aSLionel Sambuc   }
gS65*f4a2713aSLionel Sambuc   [[gnu::pure]] static int g() {
66*f4a2713aSLionel Sambuc     return 1;
67*f4a2713aSLionel Sambuc   }
68*f4a2713aSLionel Sambuc };
69*f4a2713aSLionel Sambuc 
70*f4a2713aSLionel Sambuc // CHECK: int m __attribute__((aligned(4
71*f4a2713aSLionel Sambuc // CHECK: int n alignas(4
72*f4a2713aSLionel Sambuc // CHECK: static int f() __attribute__((pure))
73*f4a2713aSLionel Sambuc // CHECK: static int g() {{\[}}[gnu::pure]]
74*f4a2713aSLionel Sambuc template struct S<int>;
75*f4a2713aSLionel Sambuc 
76*f4a2713aSLionel Sambuc // CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
77*f4a2713aSLionel Sambuc using Small2 [[gnu::mode(byte)]] = int;
78