Debian Codegraph @

clang/test/SemaCXX/cxx11-attr-print.cpp

raw
1 // RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
2 //
3 // CHECK: int x __attribute__((aligned(4)));
4 int x __attribute__((aligned(4)));
5
6 // CHECK: __declspec(align(4)) int y;
7 __declspec(align(4)) int y;
8
9 // CHECK: int z {{\[}}[gnu::aligned(4)]];
10 int z [[gnu::aligned(4)]];
11
12 // CHECK: __attribute__((deprecated("warning")));
13 int a __attribute__((deprecated("warning")));
14
15 // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
16 int b [[gnu::deprecated("warning")]];
17
18 // CHECK: __declspec(deprecated("warning"))
19 __declspec(deprecated("warning")) int c;
20
21 // CHECK: int d {{\[}}[deprecated("warning")]];
22 int d [[deprecated("warning")]];
23
24 // CHECK: __attribute__((deprecated("warning", "fixit")));
25 int e __attribute__((deprecated("warning", "fixit")));
26
27 // CHECK: alignas(4) int cxx11_alignas;
28 alignas(4) int cxx11_alignas;
29
30 // CHECK: _Alignas(int) int c11_alignas;
31 _Alignas(int) int c11_alignas;
32
33 // CHECK: int foo() __attribute__((const));
34 int foo() __attribute__((const));
35
36 // CHECK: int bar() __attribute__((__const));
37 int bar() __attribute__((__const));
38
39 // FIXME: It's unfortunate that the string literal prints with the below three
40 // cases given that the string is only exposed via the [[nodiscard]] spelling.
41 // CHECK: int f1() __attribute__((warn_unused_result("")));
42 int f1() __attribute__((warn_unused_result));
43
44 // CHECK: {{\[}}[clang::warn_unused_result("")]];
45 int f2 [[clang::warn_unused_result]] ();
46
47 // CHECK: {{\[}}[gnu::warn_unused_result("")]];
48 int f3 [[gnu::warn_unused_result]] ();
49
50 // FIXME: ast-print need to print C++11
51 // attribute after function declare-id.
52 // CHECK: {{\[}}[noreturn]];
53 void f4 [[noreturn]] ();
54
55 // CHECK: __attribute__((gnu_inline));
56 inline void f6() __attribute__((gnu_inline));
57
58 // CHECK: {{\[}}[gnu::gnu_inline]];
59 inline void f7 [[gnu::gnu_inline]] ();
60
61 // arguments printing
62 // CHECK: __attribute__((format(printf, 2, 3)));
63 void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
64
65 // CHECK: int m __attribute__((aligned(4
66 // CHECK: int n alignas(4
67 // CHECK: int p alignas(int
68 // CHECK: __attribute__((pure)) static int f()
69 // CHECK: {{\[}}[gnu::pure]] static int g()
70 template <typename T> struct S {
71 __attribute__((aligned(4))) int m;
72 alignas(4) int n;
73 alignas(int) int p;
74 __attribute__((pure)) static int f() {
75 return 0;
76 }
77 [[gnu::pure]] static int g() {
78 return 1;
79 }
80 };
81
82 // CHECK: int m __attribute__((aligned(4
83 // CHECK: int n alignas(4
84 // CHECK: __attribute__((pure)) static int f()
85 // CHECK: {{\[}}[gnu::pure]] static int g()
86 template struct S<int>;
87
88 // CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
89 using Small2 [[gnu::mode(byte)]] = int;
90
91 class FinalNonTemplate final {};
92 // CHECK: class FinalNonTemplate final {
93 template <typename T> class FinalTemplate final {};
94 // CHECK: template <typename T> class FinalTemplate final {
95
96 class alignas(8) AlignedClass {};
97 // CHECK: class alignas(8) AlignedClass {
98 template<typename T> class alignas(4) AlignedClassTemplate {};
99 // CHECK: class alignas(4) AlignedClassTemplate {