1 // RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
\r
4 __attribute__((unused));
\r
5 // CHECK: VarDecl{{.*}}TestLocation
\r
6 // CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
\r
9 __attribute__((unused));
\r
10 // CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
\r
11 // CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
\r
13 void TestAttributedStmt() {
\r
16 [[clang::fallthrough]];
\r
21 // CHECK: FunctionDecl{{.*}}TestAttributedStmt
\r
22 // CHECK: AttributedStmt
\r
23 // CHECK-NEXT: FallThroughAttr
\r
24 // CHECK-NEXT: NullStmt
\r
26 [[clang::warn_unused_result]] int TestCXX11DeclAttr();
\r
27 // CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
\r
28 // CHECK-NEXT: WarnUnusedResultAttr
\r
30 int TestAlignedNull __attribute__((aligned));
\r
31 // CHECK: VarDecl{{.*}}TestAlignedNull
\r
32 // CHECK-NEXT: AlignedAttr {{.*}} aligned
\r
33 // CHECK-NEXT: <<<NULL>>>
\r
35 int TestAlignedExpr __attribute__((aligned(4)));
\r
36 // CHECK: VarDecl{{.*}}TestAlignedExpr
\r
37 // CHECK-NEXT: AlignedAttr {{.*}} aligned
\r
38 // CHECK-NEXT: IntegerLiteral
\r
40 int TestEnum __attribute__((visibility("default")));
\r
41 // CHECK: VarDecl{{.*}}TestEnum
\r
42 // CHECK-NEXT: VisibilityAttr{{.*}} Default
\r
44 class __attribute__((lockable)) Mutex {
\r
46 int TestExpr __attribute__((guarded_by(mu1)));
\r
47 // CHECK: VarDecl{{.*}}TestExpr
\r
48 // CHECK-NEXT: GuardedByAttr
\r
49 // CHECK-NEXT: DeclRefExpr{{.*}}mu1
\r
51 class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
\r
52 // CHECK: VarDecl{{.*}}TestVariadicExpr
\r
53 // CHECK: AcquiredAfterAttr
\r
54 // CHECK-NEXT: DeclRefExpr{{.*}}mu1
\r
55 // CHECK-NEXT: DeclRefExpr{{.*}}mu2
\r
57 void function1(void *) {
\r
58 int TestFunction __attribute__((cleanup(function1)));
\r
60 // CHECK: VarDecl{{.*}}TestFunction
\r
61 // CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
\r
63 void TestIdentifier(void *, int)
\r
64 __attribute__((pointer_with_type_tag(ident1,1,2)));
\r
65 // CHECK: FunctionDecl{{.*}}TestIdentifier
\r
66 // CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
\r
68 void TestBool(void *, int)
\r
69 __attribute__((pointer_with_type_tag(bool1,1,2)));
\r
70 // CHECK: FunctionDecl{{.*}}TestBool
\r
71 // CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 1 2 IsPointer
\r
73 void TestUnsigned(void *, int)
\r
74 __attribute__((pointer_with_type_tag(unsigned1,1,2)));
\r
75 // CHECK: FunctionDecl{{.*}}TestUnsigned
\r
76 // CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 1 2
\r
78 void TestInt(void) __attribute__((constructor(123)));
\r
79 // CHECK: FunctionDecl{{.*}}TestInt
\r
80 // CHECK-NEXT: ConstructorAttr{{.*}} 123
\r
82 static int TestString __attribute__((alias("alias1")));
\r
83 // CHECK: VarDecl{{.*}}TestString
\r
84 // CHECK-NEXT: AliasAttr{{.*}} "alias1"
\r
86 extern struct s1 TestType
\r
87 __attribute__((type_tag_for_datatype(ident1,int)));
\r
88 // CHECK: VarDecl{{.*}}TestType
\r
89 // CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
\r
92 L: __attribute__((unused)) int i;
\r
93 // CHECK: LabelStmt{{.*}}'L'
\r
94 // CHECK: VarDecl{{.*}}i 'int'
\r
95 // CHECK-NEXT: UnusedAttr{{.*}}
\r
97 M: __attribute(()) int j;
\r
98 // CHECK: LabelStmt {{.*}} 'M'
\r
99 // CHECK-NEXT: DeclStmt
\r
100 // CHECK-NEXT: VarDecl {{.*}} j 'int'
\r
102 N: __attribute(()) ;
\r
103 // CHECK: LabelStmt {{.*}} 'N'
\r
104 // CHECK-NEXT: NullStmt
\r
108 extern "C" int printf(const char *format, ...);
\r
109 // CHECK: FunctionDecl{{.*}}printf
\r
110 // CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *'
\r
111 // CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2
\r
113 alignas(8) extern int x;
\r
115 // CHECK: VarDecl{{.*}} x 'int'
\r
116 // CHECK: VarDecl{{.*}} x 'int'
\r
117 // CHECK-NEXT: AlignedAttr{{.*}} Inherited
\r
120 int __attribute__((cdecl)) TestOne(void), TestTwo(void);
\r
121 // CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl))
\r
122 // CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl))
\r
125 auto Test = []() __attribute__((no_thread_safety_analysis)) {};
\r
126 // CHECK: CXXMethodDecl{{.*}}operator() 'void () const'
\r
127 // CHECK: NoThreadSafetyAnalysisAttr
\r
129 // Because GNU's noreturn applies to the function type, and this lambda does
\r
130 // not have a capture list, the call operator and the function pointer
\r
131 // conversion should both be noreturn, but the method should not contain a
\r
132 // NoReturnAttr because the attribute applied to the type.
\r
133 auto Test2 = []() __attribute__((noreturn)) { while(1); };
\r
134 // CHECK: CXXMethodDecl{{.*}}operator() 'void () __attribute__((noreturn)) const'
\r
135 // CHECK-NOT: NoReturnAttr
\r
136 // CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn))
\r
139 namespace PR20930 {
\r
141 struct { int Test __attribute__((deprecated)); };
\r
142 // CHECK: FieldDecl{{.*}}Test 'int'
\r
143 // CHECK-NEXT: DeprecatedAttr
\r
149 // CHECK: IndirectFieldDecl{{.*}}Test 'int'
\r
150 // CHECK: DeprecatedAttr
\r
154 struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
\r
155 // CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef
\r
156 // CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle
\r
158 void TestExternalSourceSymbolAttr1()
\r
159 __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
\r
160 // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr1
\r
161 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
\r
163 void TestExternalSourceSymbolAttr2()
\r
164 __attribute__((external_source_symbol(defined_in="module", language="Swift")));
\r
165 // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr2
\r
166 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module"{{$}}
\r
168 void TestExternalSourceSymbolAttr3()
\r
169 __attribute__((external_source_symbol(generated_declaration, language="Objective-C++", defined_in="module")));
\r
170 // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr3
\r
171 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Objective-C++" "module" GeneratedDeclaration
\r
173 void TestExternalSourceSymbolAttr4()
\r
174 __attribute__((external_source_symbol(defined_in="Some external file.cs", generated_declaration, language="C Sharp")));
\r
175 // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr4
\r
176 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "C Sharp" "Some external file.cs" GeneratedDeclaration
\r
178 void TestExternalSourceSymbolAttr5()
\r
179 __attribute__((external_source_symbol(generated_declaration, defined_in="module", language="Swift")));
\r
180 // CHECK: FunctionDecl{{.*}} TestExternalSourceSymbolAttr5
\r
181 // CHECK-NEXT: ExternalSourceSymbolAttr{{.*}} "Swift" "module" GeneratedDeclaration
\r
183 namespace TestNoEscape {
\r
184 void noescapeFunc(int *p0, __attribute__((noescape)) int *p1) {}
\r
185 // CHECK: `-FunctionDecl{{.*}} noescapeFunc 'void (int *, __attribute__((noescape)) int *)'
\r
186 // CHECK-NEXT: ParmVarDecl
\r
187 // CHECK-NEXT: ParmVarDecl
\r
188 // CHECK-NEXT: NoEscapeAttr
\r
191 namespace TestSuppress {
\r
192 [[gsl::suppress("at-namespace")]];
\r
193 // CHECK: NamespaceDecl{{.*}} TestSuppress
\r
194 // CHECK-NEXT: EmptyDecl{{.*}}
\r
195 // CHECK-NEXT: SuppressAttr{{.*}} at-namespace
\r
196 [[gsl::suppress("on-decl")]]
\r
197 void TestSuppressFunction();
\r
198 // CHECK: FunctionDecl{{.*}} TestSuppressFunction
\r
199 // CHECK-NEXT SuppressAttr{{.*}} on-decl
\r
204 [[gsl::suppress("on-stmt")]] {
\r
205 // CHECK: AttributedStmt
\r
206 // CHECK-NEXT: SuppressAttr{{.*}} on-stmt
\r
207 // CHECK-NEXT: CompoundStmt
\r
208 i = reinterpret_cast<int*>(7);
\r