[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ast-dump-openmp-begin-declare-variant_namespace_1.cpp
blob99e02adb6b4de4b07bfa707e4325d8dc9ca52d67
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: | | | `-NestedNameSpecifier Namespace [[ADDR_0]] 'A'
118 // CHECK-NEXT: | | `-PseudoObjectExpr [[ADDR_50:0x[a-z0-9]*]] <col:21, col:28> 'int'
119 // CHECK-NEXT: | | |-CallExpr [[ADDR_51:0x[a-z0-9]*]] <col:21, col:28> 'int'
120 // CHECK-NEXT: | | | `-ImplicitCastExpr [[ADDR_52:0x[a-z0-9]*]] <col:21, col:24> 'int (*)({{.*}})' <FunctionToPointerDecay>
121 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_53:0x[a-z0-9]*]] <col:21, col:24> 'int ({{.*}})' {{.*}}Function [[ADDR_6]] 'bar' 'int ({{.*}})'
122 // CHECK-NEXT: | | | `-NestedNameSpecifier Namespace [[ADDR_31]] 'B'
123 // CHECK-NEXT: | | `-CallExpr [[ADDR_54:0x[a-z0-9]*]] <line:34:1, line:50:28> 'int'
124 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_55:0x[a-z0-9]*]] <line:34:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
125 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_11]] <col:1> 'int ({{.*}})' Function [[ADDR_12]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
126 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_56:0x[a-z0-9]*]] <line:50:32, col:39> 'int'
127 // CHECK-NEXT: | |-CallExpr [[ADDR_57:0x[a-z0-9]*]] <col:32, col:39> 'int'
128 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_58:0x[a-z0-9]*]] <col:32, col:35> 'int (*)({{.*}})' <FunctionToPointerDecay>
129 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_59:0x[a-z0-9]*]] <col:32, col:35> 'int ({{.*}})' {{.*}}Function [[ADDR_14]] 'baz' 'int ({{.*}})'
130 // CHECK-NEXT: | | `-NestedNameSpecifier Namespace [[ADDR_13]] 'C'
131 // CHECK-NEXT: | `-CallExpr [[ADDR_60:0x[a-z0-9]*]] <line:42:1, line:50:39> 'int'
132 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_61:0x[a-z0-9]*]] <line:42:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
133 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19]] <col:1> 'int ({{.*}})' Function [[ADDR_20]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
134 // CHECK-NEXT: |-FunctionDecl [[ADDR_62:0x[a-z0-9]*]] <line:53:1, line:59:1> line:53:5 used implicit2 'int ({{.*}})'
135 // CHECK-NEXT: | `-CompoundStmt [[ADDR_63:0x[a-z0-9]*]] <col:17, line:59:1>
136 // CHECK-NEXT: | |-DeclStmt [[ADDR_64:0x[a-z0-9]*]] <line:54:3, col:20>
137 // CHECK-NEXT: | | `-UsingDirectiveDecl [[ADDR_65:0x[a-z0-9]*]] <col:3, col:19> col:19 Namespace [[ADDR_0]] 'A'
138 // CHECK-NEXT: | |-DeclStmt [[ADDR_66:0x[a-z0-9]*]] <line:55:3, col:20>
139 // CHECK-NEXT: | | `-UsingDirectiveDecl [[ADDR_67:0x[a-z0-9]*]] <col:3, col:19> col:19 Namespace [[ADDR_5]] 'B'
140 // CHECK-NEXT: | |-RecoveryExpr {{.*}} <line:57:3, col:7>
141 // CHECK-NEXT: | | `-UnresolvedLookupExpr {{.*}} <col:3>
142 // CHECK-NEXT: | `-ReturnStmt [[ADDR_68:0x[a-z0-9]*]] <line:58:3, col:22>
143 // CHECK-NEXT: | `-BinaryOperator [[ADDR_69:0x[a-z0-9]*]] <col:10, col:22> 'int' '+'
144 // CHECK-NEXT: | |-PseudoObjectExpr [[ADDR_70:0x[a-z0-9]*]] <col:10, col:14> 'int'
145 // CHECK-NEXT: | | |-CallExpr [[ADDR_71:0x[a-z0-9]*]] <col:10, col:14> 'int'
146 // CHECK-NEXT: | | | `-ImplicitCastExpr [[ADDR_72:0x[a-z0-9]*]] <col:10> 'int (*)({{.*}})' <FunctionToPointerDecay>
147 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_73:0x[a-z0-9]*]] <col:10> 'int ({{.*}})' {{.*}}Function [[ADDR_6]] 'bar' 'int ({{.*}})'
148 // CHECK-NEXT: | | `-CallExpr [[ADDR_74:0x[a-z0-9]*]] <line:34:1, line:58:14> 'int'
149 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_75:0x[a-z0-9]*]] <line:34:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
150 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_11]] <col:1> 'int ({{.*}})' Function [[ADDR_12]] 'bar[implementation={vendor(llvm)}]' 'int ({{.*}})'
151 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_76:0x[a-z0-9]*]] <line:58:18, col:22> 'int'
152 // CHECK-NEXT: | |-CallExpr [[ADDR_77:0x[a-z0-9]*]] <col:18, col:22> 'int'
153 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_78:0x[a-z0-9]*]] <col:18> 'int (*)({{.*}})' <FunctionToPointerDecay>
154 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_79:0x[a-z0-9]*]] <col:18> 'int ({{.*}})' {{.*}}Function [[ADDR_14]] 'baz' 'int ({{.*}})'
155 // CHECK-NEXT: | `-CallExpr [[ADDR_80:0x[a-z0-9]*]] <line:42:1, line:58:22> 'int'
156 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_81:0x[a-z0-9]*]] <line:42:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
157 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_19]] <col:1> 'int ({{.*}})' Function [[ADDR_20]] 'baz[implementation={vendor(llvm)}]' 'int ({{.*}})'
158 // CHECK-NEXT: `-FunctionDecl [[ADDR_82:0x[a-z0-9]*]] <line:61:1, line:64:1> line:61:5 main 'int ({{.*}})'
159 // CHECK-NEXT: `-CompoundStmt [[ADDR_83:0x[a-z0-9]*]] <col:12, line:64:1>
160 // CHECK-NEXT: `-ReturnStmt [[ADDR_84:0x[a-z0-9]*]] <line:63:3, col:34>
161 // CHECK-NEXT: `-BinaryOperator [[ADDR_85:0x[a-z0-9]*]] <col:10, col:34> 'int' '+'
162 // CHECK-NEXT: |-CallExpr [[ADDR_86:0x[a-z0-9]*]] <col:10, col:20> 'int'
163 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_87:0x[a-z0-9]*]] <col:10> 'int (*)({{.*}})' <FunctionToPointerDecay>
164 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_88:0x[a-z0-9]*]] <col:10> 'int ({{.*}})' {{.*}}Function [[ADDR_42]] 'explicit1' 'int ({{.*}})'
165 // CHECK-NEXT: `-CallExpr [[ADDR_89:0x[a-z0-9]*]] <col:24, col:34> 'int'
166 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_90:0x[a-z0-9]*]] <col:24> 'int (*)({{.*}})' <FunctionToPointerDecay>
167 // CHECK-NEXT: `-DeclRefExpr [[ADDR_91:0x[a-z0-9]*]] <col:24> 'int ({{.*}})' {{.*}}Function [[ADDR_62]] 'implicit2' 'int ({{.*}})'