1 // RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
2 
3 int TestLocation
4 __attribute__((unused));
5 // CHECK:      VarDecl{{.*}}TestLocation
6 // CHECK-NEXT:   UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
7 
8 int TestIndent
9 __attribute__((unused));
10 // CHECK:      {{^}}VarDecl{{.*TestIndent[^()]*$}}
11 // CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
12 
13 void TestAttributedStmt() {
14   switch (1) {
15   case 1:
16     [[clang::fallthrough]];
17   case 2:
18     ;
19   }
20 }
21 // CHECK:      FunctionDecl{{.*}}TestAttributedStmt
22 // CHECK:      AttributedStmt
23 // CHECK-NEXT:   FallThroughAttr
24 // CHECK-NEXT:   NullStmt
25 
26 [[clang::warn_unused_result]] int TestCXX11DeclAttr();
27 // CHECK:      FunctionDecl{{.*}}TestCXX11DeclAttr
28 // CHECK-NEXT:   WarnUnusedResultAttr
29 
30 int TestAlignedNull __attribute__((aligned));
31 // CHECK:      VarDecl{{.*}}TestAlignedNull
32 // CHECK-NEXT:   AlignedAttr
33 // CHECK-NEXT:     <<<NULL>>>
34 
35 int TestAlignedExpr __attribute__((aligned(4)));
36 // CHECK:      VarDecl{{.*}}TestAlignedExpr
37 // CHECK-NEXT:   AlignedAttr
38 // CHECK-NEXT:     IntegerLiteral
39 
40 int TestEnum __attribute__((visibility("default")));
41 // CHECK:      VarDecl{{.*}}TestEnum
42 // CHECK-NEXT:   VisibilityAttr{{.*}} Default
43 
44 class __attribute__((lockable)) Mutex {
45 } mu1, mu2;
46 int TestExpr __attribute__((guarded_by(mu1)));
47 // CHECK:      VarDecl{{.*}}TestExpr
48 // CHECK-NEXT:   GuardedByAttr
49 // CHECK-NEXT:     DeclRefExpr{{.*}}mu1
50 
51 class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
52 // CHECK:      VarDecl{{.*}}TestVariadicExpr
53 // CHECK:        AcquiredAfterAttr
54 // CHECK-NEXT:     DeclRefExpr{{.*}}mu1
55 // CHECK-NEXT:     DeclRefExpr{{.*}}mu2
56 
57 void function1(void *) {
58   int TestFunction __attribute__((cleanup(function1)));
59 }
60 // CHECK:      VarDecl{{.*}}TestFunction
61 // CHECK-NEXT:   CleanupAttr{{.*}} Function{{.*}}function1
62 
63 void TestIdentifier(void *, int)
64 __attribute__((pointer_with_type_tag(ident1,1,2)));
65 // CHECK: FunctionDecl{{.*}}TestIdentifier
66 // CHECK:   ArgumentWithTypeTagAttr{{.*}} ident1
67 
68 void TestBool(void *, int)
69 __attribute__((pointer_with_type_tag(bool1,1,2)));
70 // CHECK: FunctionDecl{{.*}}TestBool
71 // CHECK:   ArgumentWithTypeTagAttr{{.*}} IsPointer
72 
73 void TestUnsigned(void *, int)
74 __attribute__((pointer_with_type_tag(unsigned1,1,2)));
75 // CHECK: FunctionDecl{{.*}}TestUnsigned
76 // CHECK:   ArgumentWithTypeTagAttr{{.*}} 0 1
77 
78 void TestInt(void) __attribute__((constructor(123)));
79 // CHECK:      FunctionDecl{{.*}}TestInt
80 // CHECK-NEXT:   ConstructorAttr{{.*}} 123
81 
82 int TestString __attribute__((alias("alias1")));
83 // CHECK:      VarDecl{{.*}}TestString
84 // CHECK-NEXT:   AliasAttr{{.*}} "alias1"
85 
86 extern struct s1 TestType
87 __attribute__((type_tag_for_datatype(ident1,int)));
88 // CHECK:      VarDecl{{.*}}TestType
89 // CHECK-NEXT:   TypeTagForDatatypeAttr{{.*}} int
90 
91 void *TestVariadicUnsigned1(int) __attribute__((alloc_size(1)));
92 // CHECK: FunctionDecl{{.*}}TestVariadicUnsigned1
93 // CHECK:   AllocSizeAttr{{.*}} 0
94 
95 void *TestVariadicUnsigned2(int, int) __attribute__((alloc_size(1,2)));
96 // CHECK: FunctionDecl{{.*}}TestVariadicUnsigned2
97 // CHECK:   AllocSizeAttr{{.*}} 0 1
98 
99 void TestLabel() {
100 L: __attribute__((unused)) int i;
101 // CHECK: LabelStmt{{.*}}'L'
102 // CHECK: VarDecl{{.*}}i 'int'
103 // CHECK-NEXT: UnusedAttr{{.*}}
104 
105 M: __attribute(()) int j;
106 // CHECK: LabelStmt {{.*}} 'M'
107 // CHECK-NEXT: DeclStmt
108 // CHECK-NEXT: VarDecl {{.*}} j 'int'
109 
110 N: __attribute(()) ;
111 // CHECK: LabelStmt {{.*}} 'N'
112 // CHECK-NEXT: NullStmt
113 }
114