1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
2 // RUN: %clang_cc1 -fsyntax-only -ast-dump -ast-dump-filter test -std=c++11 -fcxx-exceptions %s | FileCheck %s
3 // expected-no-diagnostics
7 // CHECK-LABEL: CXXRecordDecl{{.*}} testClass1
8 // CHECK-NOT: AnnotateAttr
10 #pragma clang attribute push (__attribute__((annotate("test"))), apply_to=any(record, field, variable, function, namespace, type_alias))
13 void testMethod1(int param
);
17 testClass2
*operator -> ();
19 // CHECK-LABEL: CXXRecordDecl{{.*}} testClass2
20 // CHECK: AnnotateAttr{{.*}} "test"
21 // CHECK: CXXMethodDecl{{.*}} testMethod1
22 // CHECK-NEXT: ParmVarDecl{{.*}} param
23 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
24 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
25 // CHECK-NEXT: CXXConstructorDecl
26 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
27 // CHECK-NEXT: CXXMethodDecl{{.*}} operator->
28 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
30 #pragma clang attribute push (__attribute__((annotate("method"))), apply_to=any(record, field, variable, function, namespace, type_alias))
32 void testClass2::testMethod1(int param
) {
34 #pragma clang attribute pop
36 // CHECK-LABEL: CXXMethodDecl{{.*}}prev{{.*}} testMethod1
37 // CHECK-NEXT: ParmVarDecl{{.*}} param
38 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
39 // CHECK-NEXT: AnnotateAttr{{.*}} "method"
40 // CHECK-NEXT: CompoundStmt
41 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
42 // CHECK-NEXT: AnnotateAttr{{.*}} "method"
44 namespace testNamespace
{
46 // CHECK-LABEL: NamespaceDecl{{.*}} testNamespace
47 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
49 class testClassForward
;
50 // CHECK-LABEL: CXXRecordDecl{{.*}} testClassForward
51 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
53 namespace testNamespaceAlias
= testNamespace
;
54 // CHECK-LABEL: NamespaceAliasDecl{{.*}} testNamespaceAlias
55 // CHECK-NOT: AnnotateAttr
57 using testTypeAlias
= testClass2
;
58 // CHECK-LABEL: TypeAliasDecl{{.*}} testTypeAlias
59 // CHECK: AnnotateAttr{{.*}} "test"
61 void testCatchVariable() {
63 } catch (int testCatch
) {
67 // CHECK-LABEL: FunctionDecl{{.*}} testCatchVariable
68 // CHECK: CXXCatchStmt
69 // CHECK-NEXT: VarDecl{{.*}} testCatch
70 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
72 void testLambdaMethod() {
76 // CHECK-LABEL: FunctionDecl{{.*}} testLambdaMethod
78 // CHECK-NEXT: CXXRecordDecl
79 // CHECK: CXXMethodDecl{{.*}} operator()
80 // CHECK-NEXT: CompoundStmt
81 // CHECK-NEXT: AnnotateAttr{{.*}} "test"
83 #pragma clang attribute pop
85 #pragma clang attribute push (__attribute__((require_constant_initialization)), apply_to=variable(is_global))
88 // CHECK-LABEL: VarDecl{{.*}} testCI1
89 // CHECK-NEXT: IntegerLiteral
90 // CHECK-NEXT: ConstInitAttr
92 #pragma clang attribute pop
95 // CHECK-LABEL: VarDecl{{.*}} testNoCI
96 // CHECK-NEXT: IntegerLiteral
97 // CHECK-NOT: ConstInitAttr
99 // Check support for CXX11 style attributes
100 #pragma clang attribute push ([[noreturn]], apply_to = function)
103 // CHECK-LABEL: FunctionDecl{{.*}} testNoReturn
104 // CHECK-NEXT: CXX11NoReturnAttr
106 #pragma clang attribute pop