[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / AST / ast-dump-openmp-begin-declare-variant_namespace_1.cpp
blob3c94a8f1c4e2b8be1563c4245530e97af2077a89
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++ | FileCheck %s
3 namespace A {
4 int foo(void) { // expected-note {{candidate function}}
5 return 0;
7 } // namespace A
9 namespace B {
10 int bar(void) {
11 return 1;
13 } // namespace B
15 namespace C {
16 int baz(void) {
17 return 2;
19 } // namespace C
21 #pragma omp begin declare variant match(implementation = {vendor(llvm)})
23 // This will *not* be a specialization of A::foo(void).
24 int foo(void) { // expected-note {{candidate function}}
25 return 3;
28 namespace B {
29 // This will *not* be a specialization of A::foo(void).
30 int foo(void) {
31 return 4;
33 // This will be a specialization of B::bar(void).
34 int bar(void) {
35 return 0;
37 } // namespace B
39 using namespace C;
41 // This will be a specialization of C::baz(void).
42 int baz(void) {
43 return 0;
45 #pragma omp end declare variant
48 int explicit1() {
49 // Should return 0.
50 return A::foo() + B::bar() + C::baz();
53 int implicit2() {
54 using namespace A;
55 using namespace B;
56 // Should return 0.
57 foo(); // expected-error {{call to 'foo' is ambiguous}}
58 return bar() + baz();
61 int main() {
62 // Should return 0.
63 return explicit1() + implicit2();
66 // CHECK: |-NamespaceDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:3:11 A
67 // CHECK-NEXT: | `-FunctionDecl [[ADDR_1:0x[a-z0-9]*]] <line:4:1, line:6:1> line:4:5 used foo 'int ({{.*}})'
68 // CHECK-NEXT: | `-CompoundStmt [[ADDR_2:0x[a-z0-9]*]] <col:15, line:6:1>
69 // CHECK-NEXT: | `-ReturnStmt [[ADDR_3:0x[a-z0-9]*]] <line:5:3, col:10>
70 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_4:0x[a-z0-9]*]] <col:10> 'int' 0
71 // CHECK-NEXT: |-NamespaceDecl [[ADDR_5:0x[a-z0-9]*]] <line:9:1, line:13:1> line:9:11 B
72 // CHECK-NEXT: | `-FunctionDecl [[ADDR_6:0x[a-z0-9]*]] <line:10:1, line:12:1> line:10:5 used bar 'int ({{.*}})'
73 // CHECK-NEXT: | |-CompoundStmt [[ADDR_7:0x[a-z0-9]*]] <col:15, line:12:1>
74 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_8:0x[a-z0-9]*]] <line:11:3, col:10>
75 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_9:0x[a-z0-9]*]] <col:10> 'int' 1
76 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_10:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(llvm)}
77 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_11:0x[a-z0-9]*]] <line:34:1> 'int ({{.*}})' Function [[ADDR_12:0x[a-z0-9]*]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
78 // CHECK-NEXT: |-NamespaceDecl [[ADDR_13:0x[a-z0-9]*]] <line:15:1, line:19:1> line:15:11 C
79 // CHECK-NEXT: | `-FunctionDecl [[ADDR_14:0x[a-z0-9]*]] <line:16:1, line:18:1> line:16:5 used baz 'int ({{.*}})'
80 // CHECK-NEXT: | |-CompoundStmt [[ADDR_15:0x[a-z0-9]*]] <col:15, line:18:1>
81 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_16:0x[a-z0-9]*]] <line:17:3, col:10>
82 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_17:0x[a-z0-9]*]] <col:10> 'int' 2
83 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_18:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(llvm)}
84 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19:0x[a-z0-9]*]] <line:42:1> 'int ({{.*}})' Function [[ADDR_20:0x[a-z0-9]*]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
85 // CHECK-NEXT: |-FunctionDecl [[ADDR_21:0x[a-z0-9]*]] <line:24:1, col:13> col:5 implicit foo 'int ({{.*}})'
86 // CHECK-NEXT: | |-OMPDeclareVariantAttr [[ADDR_22:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(llvm)}
87 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_23:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' Function [[ADDR_24:0x[a-z0-9]*]] 'foo[implementation={vendor(llvm)}]' 'int ({{.*}})'
88 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_25:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(llvm)}
89 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_26:0x[a-z0-9]*]] <line:30:1> 'int ({{.*}})' Function [[ADDR_27:0x[a-z0-9]*]] 'foo[implementation={vendor(llvm)}]' 'int ({{.*}})'
90 // CHECK-NEXT: |-FunctionDecl [[ADDR_24]] <line:24:1, line:26:1> line:24:1 foo[implementation={vendor(llvm)}] 'int ({{.*}})'
91 // CHECK-NEXT: | `-CompoundStmt [[ADDR_28:0x[a-z0-9]*]] <col:15, line:26:1>
92 // CHECK-NEXT: | `-ReturnStmt [[ADDR_29:0x[a-z0-9]*]] <line:25:3, col:10>
93 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_30:0x[a-z0-9]*]] <col:10> 'int' 3
94 // CHECK-NEXT: |-NamespaceDecl [[ADDR_31:0x[a-z0-9]*]] prev [[ADDR_5]] <line:28:1, line:37:1> line:28:11 B
95 // CHECK-NEXT: | |-original Namespace [[ADDR_5]] 'B'
96 // CHECK-NEXT: | |-FunctionDecl [[ADDR_27]] <line:30:1, line:32:1> line:30:1 foo[implementation={vendor(llvm)}] 'int ({{.*}})'
97 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_32:0x[a-z0-9]*]] <col:15, line:32:1>
98 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_33:0x[a-z0-9]*]] <line:31:3, col:10>
99 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_34:0x[a-z0-9]*]] <col:10> 'int' 4
100 // CHECK-NEXT: | `-FunctionDecl [[ADDR_12]] <line:34:1, line:36:1> line:34:1 bar[implementation={vendor(llvm)}] 'int ({{.*}})'
101 // CHECK-NEXT: | `-CompoundStmt [[ADDR_35:0x[a-z0-9]*]] <col:15, line:36:1>
102 // CHECK-NEXT: | `-ReturnStmt [[ADDR_36:0x[a-z0-9]*]] <line:35:3, col:10>
103 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_37:0x[a-z0-9]*]] <col:10> 'int' 0
104 // CHECK-NEXT: |-UsingDirectiveDecl [[ADDR_38:0x[a-z0-9]*]] <line:39:1, col:17> col:17 Namespace [[ADDR_13]] 'C'
105 // CHECK-NEXT: |-FunctionDecl [[ADDR_20]] <line:42:1, line:44:1> line:42:1 baz[implementation={vendor(llvm)}] 'int ({{.*}})'
106 // CHECK-NEXT: | `-CompoundStmt [[ADDR_39:0x[a-z0-9]*]] <col:15, line:44:1>
107 // CHECK-NEXT: | `-ReturnStmt [[ADDR_40:0x[a-z0-9]*]] <line:43:3, col:10>
108 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_41:0x[a-z0-9]*]] <col:10> 'int' 0
109 // CHECK-NEXT: |-FunctionDecl [[ADDR_42:0x[a-z0-9]*]] <line:48:1, line:51:1> line:48:5 used explicit1 'int ({{.*}})'
110 // CHECK-NEXT: | `-CompoundStmt [[ADDR_43:0x[a-z0-9]*]] <col:17, line:51:1>
111 // CHECK-NEXT: | `-ReturnStmt [[ADDR_44:0x[a-z0-9]*]] <line:50:3, col:39>
112 // CHECK-NEXT: | `-BinaryOperator [[ADDR_45:0x[a-z0-9]*]] <col:10, col:39> 'int' '+'
113 // CHECK-NEXT: | |-BinaryOperator [[ADDR_46:0x[a-z0-9]*]] <col:10, col:28> 'int' '+'
114 // CHECK-NEXT: | | |-CallExpr [[ADDR_47:0x[a-z0-9]*]] <col:10, col:17> 'int'
115 // CHECK-NEXT: | | | `-ImplicitCastExpr [[ADDR_48:0x[a-z0-9]*]] <col:10, col:13> 'int (*)({{.*}})' <FunctionToPointerDecay>
116 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_49:0x[a-z0-9]*]] <col:10, col:13> 'int ({{.*}})' {{.*}}Function [[ADDR_1]] 'foo' 'int ({{.*}})'
117 // CHECK-NEXT: | | `-PseudoObjectExpr [[ADDR_50:0x[a-z0-9]*]] <col:21, col:28> 'int'
118 // CHECK-NEXT: | | |-CallExpr [[ADDR_51:0x[a-z0-9]*]] <col:21, col:28> 'int'
119 // CHECK-NEXT: | | | `-ImplicitCastExpr [[ADDR_52:0x[a-z0-9]*]] <col:21, col:24> 'int (*)({{.*}})' <FunctionToPointerDecay>
120 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_53:0x[a-z0-9]*]] <col:21, col:24> 'int ({{.*}})' {{.*}}Function [[ADDR_6]] 'bar' 'int ({{.*}})'
121 // CHECK-NEXT: | | `-CallExpr [[ADDR_54:0x[a-z0-9]*]] <line:34:1, line:50:28> 'int'
122 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_55:0x[a-z0-9]*]] <line:34:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
123 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_11]] <col:1> 'int ({{.*}})' Function [[ADDR_12]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
124 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_56:0x[a-z0-9]*]] <line:50:32, col:39> 'int'
125 // CHECK-NEXT: | |-CallExpr [[ADDR_57:0x[a-z0-9]*]] <col:32, col:39> 'int'
126 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_58:0x[a-z0-9]*]] <col:32, col:35> 'int (*)({{.*}})' <FunctionToPointerDecay>
127 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_59:0x[a-z0-9]*]] <col:32, col:35> 'int ({{.*}})' {{.*}}Function [[ADDR_14]] 'baz' 'int ({{.*}})'
128 // CHECK-NEXT: | `-CallExpr [[ADDR_60:0x[a-z0-9]*]] <line:42:1, line:50:39> 'int'
129 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_61:0x[a-z0-9]*]] <line:42:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
130 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19]] <col:1> 'int ({{.*}})' Function [[ADDR_20]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
131 // CHECK-NEXT: |-FunctionDecl [[ADDR_62:0x[a-z0-9]*]] <line:53:1, line:59:1> line:53:5 used implicit2 'int ({{.*}})'
132 // CHECK-NEXT: | `-CompoundStmt [[ADDR_63:0x[a-z0-9]*]] <col:17, line:59:1>
133 // CHECK-NEXT: | |-DeclStmt [[ADDR_64:0x[a-z0-9]*]] <line:54:3, col:20>
134 // CHECK-NEXT: | | `-UsingDirectiveDecl [[ADDR_65:0x[a-z0-9]*]] <col:3, col:19> col:19 Namespace [[ADDR_0]] 'A'
135 // CHECK-NEXT: | |-DeclStmt [[ADDR_66:0x[a-z0-9]*]] <line:55:3, col:20>
136 // CHECK-NEXT: | | `-UsingDirectiveDecl [[ADDR_67:0x[a-z0-9]*]] <col:3, col:19> col:19 Namespace [[ADDR_5]] 'B'
137 // CHECK-NEXT: | |-RecoveryExpr {{.*}} <line:57:3, col:7>
138 // CHECK-NEXT: | | `-UnresolvedLookupExpr {{.*}} <col:3>
139 // CHECK-NEXT: | `-ReturnStmt [[ADDR_68:0x[a-z0-9]*]] <line:58:3, col:22>
140 // CHECK-NEXT: | `-BinaryOperator [[ADDR_69:0x[a-z0-9]*]] <col:10, col:22> 'int' '+'
141 // CHECK-NEXT: | |-PseudoObjectExpr [[ADDR_70:0x[a-z0-9]*]] <col:10, col:14> 'int'
142 // CHECK-NEXT: | | |-CallExpr [[ADDR_71:0x[a-z0-9]*]] <col:10, col:14> 'int'
143 // CHECK-NEXT: | | | `-ImplicitCastExpr [[ADDR_72:0x[a-z0-9]*]] <col:10> 'int (*)({{.*}})' <FunctionToPointerDecay>
144 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_73:0x[a-z0-9]*]] <col:10> 'int ({{.*}})' {{.*}}Function [[ADDR_6]] 'bar' 'int ({{.*}})'
145 // CHECK-NEXT: | | `-CallExpr [[ADDR_74:0x[a-z0-9]*]] <line:34:1, line:58:14> 'int'
146 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_75:0x[a-z0-9]*]] <line:34:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
147 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_11]] <col:1> 'int ({{.*}})' Function [[ADDR_12]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
148 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_76:0x[a-z0-9]*]] <line:58:18, col:22> 'int'
149 // CHECK-NEXT: | |-CallExpr [[ADDR_77:0x[a-z0-9]*]] <col:18, col:22> 'int'
150 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_78:0x[a-z0-9]*]] <col:18> 'int (*)({{.*}})' <FunctionToPointerDecay>
151 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_79:0x[a-z0-9]*]] <col:18> 'int ({{.*}})' {{.*}}Function [[ADDR_14]] 'baz' 'int ({{.*}})'
152 // CHECK-NEXT: | `-CallExpr [[ADDR_80:0x[a-z0-9]*]] <line:42:1, line:58:22> 'int'
153 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_81:0x[a-z0-9]*]] <line:42:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
154 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19]] <col:1> 'int ({{.*}})' Function [[ADDR_20]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
155 // CHECK-NEXT: `-FunctionDecl [[ADDR_82:0x[a-z0-9]*]] <line:61:1, line:64:1> line:61:5 main 'int ({{.*}})'
156 // CHECK-NEXT: `-CompoundStmt [[ADDR_83:0x[a-z0-9]*]] <col:12, line:64:1>
157 // CHECK-NEXT: `-ReturnStmt [[ADDR_84:0x[a-z0-9]*]] <line:63:3, col:34>
158 // CHECK-NEXT: `-BinaryOperator [[ADDR_85:0x[a-z0-9]*]] <col:10, col:34> 'int' '+'
159 // CHECK-NEXT: |-CallExpr [[ADDR_86:0x[a-z0-9]*]] <col:10, col:20> 'int'
160 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_87:0x[a-z0-9]*]] <col:10> 'int (*)({{.*}})' <FunctionToPointerDecay>
161 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_88:0x[a-z0-9]*]] <col:10> 'int ({{.*}})' {{.*}}Function [[ADDR_42]] 'explicit1' 'int ({{.*}})'
162 // CHECK-NEXT: `-CallExpr [[ADDR_89:0x[a-z0-9]*]] <col:24, col:34> 'int'
163 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_90:0x[a-z0-9]*]] <col:24> 'int (*)({{.*}})' <FunctionToPointerDecay>
164 // CHECK-NEXT: `-DeclRefExpr [[ADDR_91:0x[a-z0-9]*]] <col:24> 'int ({{.*}})' {{.*}}Function [[ADDR_62]] 'implicit2' 'int ({{.*}})'