1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
// 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
int TestLocation
__attribute__((unused));
// CHECK: VarDecl{{.*}}TestLocation
// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
int TestIndent
__attribute__((unused));
// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
void TestAttributedStmt() {
switch (1) {
case 1:
[[clang::fallthrough]];
case 2:
;
}
}
// CHECK: FunctionDecl{{.*}}TestAttributedStmt
// CHECK: AttributedStmt
// CHECK-NEXT: FallThroughAttr
// CHECK-NEXT: NullStmt
[[clang::warn_unused_result]] int TestCXX11DeclAttr();
// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
// CHECK-NEXT: WarnUnusedResultAttr
int TestAlignedNull __attribute__((aligned));
// CHECK: VarDecl{{.*}}TestAlignedNull
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: <<<NULL>>>
int TestAlignedExpr __attribute__((aligned(4)));
// CHECK: VarDecl{{.*}}TestAlignedExpr
// CHECK-NEXT: AlignedAttr {{.*}} aligned
// CHECK-NEXT: IntegerLiteral
int TestEnum __attribute__((visibility("default")));
// CHECK: VarDecl{{.*}}TestEnum
// CHECK-NEXT: VisibilityAttr{{.*}} Default
class __attribute__((lockable)) Mutex {
} mu1, mu2;
int TestExpr __attribute__((guarded_by(mu1)));
// CHECK: VarDecl{{.*}}TestExpr
// CHECK-NEXT: GuardedByAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
// CHECK: VarDecl{{.*}}TestVariadicExpr
// CHECK: AcquiredAfterAttr
// CHECK-NEXT: DeclRefExpr{{.*}}mu1
// CHECK-NEXT: DeclRefExpr{{.*}}mu2
void function1(void *) {
int TestFunction __attribute__((cleanup(function1)));
}
// CHECK: VarDecl{{.*}}TestFunction
// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
void TestIdentifier(void *, int)
__attribute__((pointer_with_type_tag(ident1,1,2)));
// CHECK: FunctionDecl{{.*}}TestIdentifier
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
void TestBool(void *, int)
__attribute__((pointer_with_type_tag(bool1,1,2)));
// CHECK: FunctionDecl{{.*}}TestBool
// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 0 1 IsPointer
void TestUnsigned(void *, int)
__attribute__((pointer_with_type_tag(unsigned1,1,2)));
// CHECK: FunctionDecl{{.*}}TestUnsigned
// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 0 1
void TestInt(void) __attribute__((constructor(123)));
// CHECK: FunctionDecl{{.*}}TestInt
// CHECK-NEXT: ConstructorAttr{{.*}} 123
static int TestString __attribute__((alias("alias1")));
// CHECK: VarDecl{{.*}}TestString
// CHECK-NEXT: AliasAttr{{.*}} "alias1"
extern struct s1 TestType
__attribute__((type_tag_for_datatype(ident1,int)));
// CHECK: VarDecl{{.*}}TestType
// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
void TestLabel() {
L: __attribute__((unused)) int i;
// CHECK: LabelStmt{{.*}}'L'
// CHECK: VarDecl{{.*}}i 'int'
// CHECK-NEXT: UnusedAttr{{.*}}
M: __attribute(()) int j;
// CHECK: LabelStmt {{.*}} 'M'
// CHECK-NEXT: DeclStmt
// CHECK-NEXT: VarDecl {{.*}} j 'int'
N: __attribute(()) ;
// CHECK: LabelStmt {{.*}} 'N'
// CHECK-NEXT: NullStmt
}
namespace Test {
extern "C" int printf(const char *format, ...);
// CHECK: FunctionDecl{{.*}}printf
// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *'
// CHECK-NEXT: FormatAttr{{.*}}Implicit printf 1 2
alignas(8) extern int x;
extern int x;
// CHECK: VarDecl{{.*}} x 'int'
// CHECK: VarDecl{{.*}} x 'int'
// CHECK-NEXT: AlignedAttr{{.*}} Inherited
}
int __attribute__((cdecl)) TestOne(void), TestTwo(void);
// CHECK: FunctionDecl{{.*}}TestOne{{.*}}__attribute__((cdecl))
// CHECK: FunctionDecl{{.*}}TestTwo{{.*}}__attribute__((cdecl))
void func() {
auto Test = []() __attribute__((no_thread_safety_analysis)) {};
// CHECK: CXXMethodDecl{{.*}}operator() 'void (void) const'
// CHECK: NoThreadSafetyAnalysisAttr
// Because GNU's noreturn applies to the function type, and this lambda does
// not have a capture list, the call operator and the function pointer
// conversion should both be noreturn, but the method should not contain a
// NoReturnAttr because the attribute applied to the type.
auto Test2 = []() __attribute__((noreturn)) { while(1); };
// CHECK: CXXMethodDecl{{.*}}operator() 'void (void) __attribute__((noreturn)) const'
// CHECK-NOT: NoReturnAttr
// CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn))
}
namespace PR20930 {
struct S {
struct { int Test __attribute__((deprecated)); };
// CHECK: FieldDecl{{.*}}Test 'int'
// CHECK-NEXT: DeprecatedAttr
};
void f() {
S s;
s.Test = 1;
// CHECK: IndirectFieldDecl{{.*}}Test 'int'
// CHECK: DeprecatedAttr
}
}
struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef
// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle
|