1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
3 // expected-no-diagnostics
5 template <typename A
, typename B
>
6 int template_number_mismatch_1() {
10 template <typename A
, typename B
>
11 int template_number_mismatch_2() {
15 #pragma omp begin declare variant match(implementation = {extension(allow_templates)})
17 int template_number_mismatch_1() {
21 int template_number_mismatch_2() {
24 #pragma omp end declare variant
28 return template_number_mismatch_1
<int, float>() + template_number_mismatch_2
<double>();
31 // CHECK: |-FunctionTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:8:1> line:6:5 template_number_mismatch_1
32 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_1:0x[a-z0-9]*]] <line:5:11, col:20> col:20 typename depth 0 index 0 A
33 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_2:0x[a-z0-9]*]] <col:23, col:32> col:32 typename depth 0 index 1 B
34 // CHECK-NEXT: | |-FunctionDecl [[ADDR_3:0x[a-z0-9]*]] <line:6:1, line:8:1> line:6:5 template_number_mismatch_1 'int ({{.*}})'
35 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_4:0x[a-z0-9]*]] <col:34, line:8:1>
36 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_5:0x[a-z0-9]*]] <line:7:3, col:10>
37 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_6:0x[a-z0-9]*]] <col:10> 'int' 0
38 // CHECK-NEXT: | `-FunctionDecl [[ADDR_7:0x[a-z0-9]*]] <line:6:1, line:8:1> line:6:5 used template_number_mismatch_1 'int ({{.*}})'
39 // CHECK-NEXT: | |-TemplateArgument type 'int'
40 // CHECK-NEXT: | | `-BuiltinType [[ADDR_8:0x[a-z0-9]*]] 'int'
41 // CHECK-NEXT: | |-TemplateArgument type 'float'
42 // CHECK-NEXT: | | `-BuiltinType [[ADDR_9:0x[a-z0-9]*]] 'float'
43 // CHECK-NEXT: | `-CompoundStmt [[ADDR_10:0x[a-z0-9]*]] <col:34, line:8:1>
44 // CHECK-NEXT: | `-ReturnStmt [[ADDR_11:0x[a-z0-9]*]] <line:7:3, col:10>
45 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_6]] <col:10> 'int' 0
46 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_12:0x[a-z0-9]*]] <line:10:1, line:13:1> line:11:5 template_number_mismatch_2
47 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_13:0x[a-z0-9]*]] <line:10:11, col:20> col:20 typename depth 0 index 0 A
48 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_14:0x[a-z0-9]*]] <col:23, col:32> col:32 typename depth 0 index 1 B
49 // CHECK-NEXT: | `-FunctionDecl [[ADDR_15:0x[a-z0-9]*]] <line:11:1, line:13:1> line:11:5 template_number_mismatch_2 'int ({{.*}})'
50 // CHECK-NEXT: | `-CompoundStmt [[ADDR_16:0x[a-z0-9]*]] <col:34, line:13:1>
51 // CHECK-NEXT: | `-ReturnStmt [[ADDR_17:0x[a-z0-9]*]] <line:12:3, col:10>
52 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_18:0x[a-z0-9]*]] <col:10> 'int' 1
53 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_19:0x[a-z0-9]*]] <line:16:1, line:17:32> col:5 implicit template_number_mismatch_1
54 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_20:0x[a-z0-9]*]] <line:16:11, col:20> col:20 typename depth 0 index 0 Q
55 // CHECK-NEXT: | `-FunctionDecl [[ADDR_21:0x[a-z0-9]*]] <line:17:1, col:32> col:5 template_number_mismatch_1 'int ({{.*}})'
56 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_22:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={extension(allow_templates)}
57 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_23:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_24:0x[a-z0-9]*]] 'template_number_mismatch_1[implementation={extension(allow_templates)}]' 'int ({{.*}})'
58 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_25:0x[a-z0-9]*]] <line:16:1, line:19:1> line:17:1 template_number_mismatch_1[implementation={extension(allow_templates)}]
59 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_20]] <line:16:11, col:20> col:20 typename depth 0 index 0 Q
60 // CHECK-NEXT: | `-FunctionDecl [[ADDR_24]] <line:17:1, line:19:1> line:17:1 template_number_mismatch_1[implementation={extension(allow_templates)}] 'int ({{.*}})'
61 // CHECK-NEXT: | `-CompoundStmt [[ADDR_26:0x[a-z0-9]*]] <col:34, line:19:1>
62 // CHECK-NEXT: | `-ReturnStmt [[ADDR_27:0x[a-z0-9]*]] <line:18:3, col:10>
63 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_28:0x[a-z0-9]*]] <col:10> 'int' 2
64 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_29:0x[a-z0-9]*]] <line:20:1, line:21:32> col:5 implicit template_number_mismatch_2
65 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_30:0x[a-z0-9]*]] <line:20:11, col:20> col:20 typename depth 0 index 0 Q
66 // CHECK-NEXT: | |-FunctionDecl [[ADDR_31:0x[a-z0-9]*]] <line:21:1, col:32> col:5 template_number_mismatch_2 'int ({{.*}})'
67 // CHECK-NEXT: | | `-OMPDeclareVariantAttr [[ADDR_32:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={extension(allow_templates)}
68 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_33:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_34:0x[a-z0-9]*]] 'template_number_mismatch_2[implementation={extension(allow_templates)}]' 'int ({{.*}})'
69 // CHECK-NEXT: | `-FunctionDecl [[ADDR_35:0x[a-z0-9]*]] <col:1, col:32> col:5 used template_number_mismatch_2 'int ({{.*}})'
70 // CHECK-NEXT: | |-TemplateArgument type 'double'
71 // CHECK-NEXT: | | `-BuiltinType [[ADDR_36:0x[a-z0-9]*]] 'double'
72 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_37:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={extension(allow_templates)}
73 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_38:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_39:0x[a-z0-9]*]] 'template_number_mismatch_2[implementation={extension(allow_templates)}]' 'int ({{.*}})'
74 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_40:0x[a-z0-9]*]] <line:20:1, line:23:1> line:21:1 template_number_mismatch_2[implementation={extension(allow_templates)}]
75 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_30]] <line:20:11, col:20> col:20 typename depth 0 index 0 Q
76 // CHECK-NEXT: | |-FunctionDecl [[ADDR_34]] <line:21:1, line:23:1> line:21:1 referenced template_number_mismatch_2[implementation={extension(allow_templates)}] 'int ({{.*}})'
77 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_41:0x[a-z0-9]*]] <col:34, line:23:1>
78 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_42:0x[a-z0-9]*]] <line:22:3, col:10>
79 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_43:0x[a-z0-9]*]] <col:10> 'int' 0
80 // CHECK-NEXT: | `-FunctionDecl [[ADDR_39]] <line:21:1, line:23:1> line:21:1 template_number_mismatch_2[implementation={extension(allow_templates)}] 'int ({{.*}})'
81 // CHECK-NEXT: | |-TemplateArgument type 'double'
82 // CHECK-NEXT: | | `-BuiltinType [[ADDR_36]] 'double'
83 // CHECK-NEXT: | `-CompoundStmt [[ADDR_44:0x[a-z0-9]*]] <col:34, line:23:1>
84 // CHECK-NEXT: | `-ReturnStmt [[ADDR_45:0x[a-z0-9]*]] <line:22:3, col:10>
85 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_43]] <col:10> 'int' 0
86 // CHECK-NEXT: `-FunctionDecl [[ADDR_46:0x[a-z0-9]*]] <line:26:1, line:29:1> line:26:5 test 'int ({{.*}})'
87 // CHECK-NEXT: `-CompoundStmt [[ADDR_47:0x[a-z0-9]*]] <col:12, line:29:1>
88 // CHECK-NEXT: `-ReturnStmt [[ADDR_48:0x[a-z0-9]*]] <line:28:3, col:88>
89 // CHECK-NEXT: `-BinaryOperator [[ADDR_49:0x[a-z0-9]*]] <col:10, col:88> 'int' '+'
90 // CHECK-NEXT: |-CallExpr [[ADDR_50:0x[a-z0-9]*]] <col:10, col:49> 'int'
91 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_51:0x[a-z0-9]*]] <col:10, col:47> 'int (*)({{.*}})' <FunctionToPointerDecay>
92 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_52:0x[a-z0-9]*]] <col:10, col:47> 'int ({{.*}})' {{.*}}Function [[ADDR_7]] 'template_number_mismatch_1' 'int ({{.*}})' (FunctionTemplate [[ADDR_0]] 'template_number_mismatch_1')
93 // CHECK-NEXT: `-PseudoObjectExpr [[ADDR_53:0x[a-z0-9]*]] <col:53, col:88> 'int'
94 // CHECK-NEXT: |-CallExpr [[ADDR_54:0x[a-z0-9]*]] <col:53, col:88> 'int'
95 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_55:0x[a-z0-9]*]] <col:53, col:86> 'int (*)({{.*}})' <FunctionToPointerDecay>
96 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_56:0x[a-z0-9]*]] <col:53, col:86> 'int ({{.*}})' {{.*}}Function [[ADDR_35]] 'template_number_mismatch_2' 'int ({{.*}})' (FunctionTemplate [[ADDR_29]] 'template_number_mismatch_2')
97 // CHECK-NEXT: `-CallExpr [[ADDR_57:0x[a-z0-9]*]] <line:21:1, line:28:88> 'int'
98 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_58:0x[a-z0-9]*]] <line:21:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
99 // CHECK-NEXT: `-DeclRefExpr [[ADDR_38]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_39]] 'template_number_mismatch_2[implementation={extension(allow_templates)}]' 'int ({{.*}})'