[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / cxx11-attr-print.cpp
blob2b084018bc066223e580b58fe2f60e33af50aa22
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)));
6 // CHECK: __declspec(align(4)) int y;
7 __declspec(align(4)) int y;
9 // CHECK: int z {{\[}}[gnu::aligned(4)]];
10 int z [[gnu::aligned(4)]];
12 // CHECK: __attribute__((deprecated("warning")));
13 int a __attribute__((deprecated("warning")));
15 // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
16 int b [[gnu::deprecated("warning")]];
18 // CHECK: __declspec(deprecated("warning"))
19 __declspec(deprecated("warning")) int c;
21 // CHECK: int d {{\[}}[deprecated("warning")]];
22 int d [[deprecated("warning")]];
24 // CHECK: __attribute__((deprecated("warning", "fixit")));
25 int e __attribute__((deprecated("warning", "fixit")));
27 // CHECK: alignas(4) int cxx11_alignas;
28 alignas(4) int cxx11_alignas;
30 // CHECK: _Alignas(int) int c11_alignas;
31 _Alignas(int) int c11_alignas;
33 // CHECK: int foo() __attribute__((const));
34 int foo() __attribute__((const));
36 // CHECK: int bar() __attribute__((__const));
37 int bar() __attribute__((__const));
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));
44 // CHECK: {{\[}}[clang::warn_unused_result("")]];
45 int f2 [[clang::warn_unused_result]] ();
47 // CHECK: {{\[}}[gnu::warn_unused_result("")]];
48 int f3 [[gnu::warn_unused_result]] ();
50 // FIXME: ast-print need to print C++11
51 // attribute after function declare-id.
52 // CHECK: {{\[}}[noreturn]];
53 void f4 [[noreturn]] ();
55 // CHECK: __attribute__((gnu_inline));
56 inline void f6() __attribute__((gnu_inline));
58 // CHECK: {{\[}}[gnu::gnu_inline]];
59 inline void f7 [[gnu::gnu_inline]] ();
61 // arguments printing
62 // CHECK: __attribute__((format(printf, 2, 3)));
63 void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
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;
77 [[gnu::pure]] static int g() {
78 return 1;
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>;
88 // CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
89 using Small2 [[gnu::mode(byte)]] = int;
91 class FinalNonTemplate final {};
92 // CHECK: class FinalNonTemplate final {
93 template <typename T> class FinalTemplate final {};
94 // CHECK: template <typename T> class FinalTemplate final {