Mercurial > hg > CbC > CbC_llvm
comparison llvm/test/TableGen/template-args.td @ 252:1f2b6ac9f198 llvm-original
LLVM16-1
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Aug 2023 09:04:13 +0900 |
parents | 79ff65ed7e25 |
children |
comparison
equal
deleted
inserted
replaced
237:c80f45b162ad | 252:1f2b6ac9f198 |
---|---|
4 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s | 4 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s |
5 // RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s | 5 // RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s |
6 // RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s | 6 // RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s |
7 // RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s | 7 // RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s |
8 // RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s | 8 // RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s |
9 // RUN: not llvm-tblgen -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s | |
10 // RUN: not llvm-tblgen -DERROR9 %s 2>&1 | FileCheck --check-prefix=ERROR9 %s | |
11 // RUN: not llvm-tblgen -DERROR10 %s 2>&1 | FileCheck --check-prefix=ERROR10 %s | |
9 | 12 |
10 // This file tests that template arguments are type-checked and cast | 13 // This file tests that all required arguments are specified and template |
11 // if necessary. | 14 // arguments are type-checked and cast if necessary. |
12 | 15 |
13 // Class template arguments. | 16 // Class template arguments. |
14 | 17 |
15 class Class1<string nm> { | 18 class Class1<string nm> { |
16 string Name = nm; | 19 string Name = nm; |
23 def Rec1 : Class1<"Alice"> { | 26 def Rec1 : Class1<"Alice"> { |
24 string NameName = Name # Name; | 27 string NameName = Name # Name; |
25 } | 28 } |
26 | 29 |
27 #ifdef ERROR1 | 30 #ifdef ERROR1 |
28 // ERROR1: Value specified for template argument 'Class1:nm' (#0) is of type int | 31 // ERROR1: Value specified for template argument 'Class1:nm' is of type int |
29 | 32 |
30 def Rec2 : Class1<42> { | 33 def Rec2 : Class1<42> { |
31 } | 34 } |
32 #endif | 35 #endif |
33 | 36 |
50 def Rec4 : Class2<42> { | 53 def Rec4 : Class2<42> { |
51 list<int> CodeList = [Code]; | 54 list<int> CodeList = [Code]; |
52 } | 55 } |
53 | 56 |
54 #ifdef ERROR2 | 57 #ifdef ERROR2 |
55 // ERROR2: Value specified for template argument 'Class2:cd' (#0) is of type string | 58 // ERROR2: Value specified for template argument 'Class2:cd' is of type string |
56 | 59 |
57 def Rec5 : Class2<"oops"> { | 60 def Rec5 : Class2<"oops"> { |
58 list<int> CodeList = [Code]; | 61 list<int> CodeList = [Code]; |
59 } | 62 } |
60 #endif | 63 #endif |
67 def Rec6 { | 70 def Rec6 { |
68 string Name = Class1<"Ted">.Name; | 71 string Name = Class1<"Ted">.Name; |
69 } | 72 } |
70 | 73 |
71 #ifdef ERROR3 | 74 #ifdef ERROR3 |
72 // ERROR3: Value specified for template argument 'Class1:nm' (#0) is of type int | 75 // ERROR3: Value specified for template argument 'Class1:nm' is of type int |
73 | 76 |
74 def Rec7 { | 77 def Rec7 { |
75 string Name = Class1<42>.Name; | 78 string Name = Class1<42>.Name; |
76 } | 79 } |
77 #endif | 80 #endif |
82 def Rec8 { | 85 def Rec8 { |
83 list<int> CodeList = [Class2<42>.Code]; | 86 list<int> CodeList = [Class2<42>.Code]; |
84 } | 87 } |
85 | 88 |
86 #ifdef ERROR4 | 89 #ifdef ERROR4 |
87 // ERROR4: Value specified for template argument 'Class2:cd' (#0) is of type string | 90 // ERROR4: Value specified for template argument 'Class2:cd' is of type string |
88 | 91 |
89 def Rec9 { | 92 def Rec9 { |
90 list<int> CodeList = [Class2<"huh?">.Code]; | 93 list<int> CodeList = [Class2<"huh?">.Code]; |
91 } | 94 } |
92 #endif | 95 #endif |
108 // CHECK: string NameNmae = "CarolCarol" | 111 // CHECK: string NameNmae = "CarolCarol" |
109 | 112 |
110 defm RecMC1 : MC1<"Carol">; | 113 defm RecMC1 : MC1<"Carol">; |
111 | 114 |
112 #ifdef ERROR5 | 115 #ifdef ERROR5 |
113 // ERROR5: Value specified for template argument 'MC1::nm' (#0) is of type int | 116 // ERROR5: Value specified for template argument 'MC1::nm' is of type int |
114 | 117 |
115 defm RecMC2 : MC1<42>; | 118 defm RecMC2 : MC1<42>; |
116 #endif | 119 #endif |
117 | 120 |
118 multiclass MC2<bits<8> cd> { | 121 multiclass MC2<bits<8> cd> { |
135 // CHECK: list<int> CodeList = [42] | 138 // CHECK: list<int> CodeList = [42] |
136 | 139 |
137 defm RecMC3 : MC2<42>; | 140 defm RecMC3 : MC2<42>; |
138 | 141 |
139 #ifdef ERROR6 | 142 #ifdef ERROR6 |
140 // ERROR6: Value specified for template argument 'MC2::cd' (#0) is of type string | 143 // ERROR6: Value specified for template argument 'MC2::cd' is of type string |
141 | 144 |
142 defm RecMC4 : MC2<"Bob">; | 145 defm RecMC4 : MC2<"Bob">; |
143 #endif | 146 #endif |
144 | 147 |
145 #ifdef ERROR7 | 148 #ifdef ERROR7 |
149 } | 152 } |
150 defm Good : TwoArgs<1, "one">; | 153 defm Good : TwoArgs<1, "one">; |
151 defm MissingComma : TwoArgs<2 "two">; | 154 defm MissingComma : TwoArgs<2 "two">; |
152 // ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument | 155 // ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument |
153 #endif | 156 #endif |
157 | |
158 #ifdef ERROR8 | |
159 def error8: Class1; | |
160 // ERROR8: value not specified for template argument 'Class1:nm' | |
161 // ERROR8: 18:21: note: declared in 'Class1' | |
162 #endif | |
163 | |
164 #ifdef ERROR9 | |
165 defm error9: MC1; | |
166 // ERROR9: value not specified for template argument 'MC1::nm' | |
167 // ERROR9: 99:23: note: declared in 'MC1' | |
168 #endif | |
169 | |
170 #ifdef ERROR10 | |
171 def error10 { | |
172 int value = Class2<>.Code; | |
173 } | |
174 // ERROR10: value not specified for template argument 'Class2:cd' | |
175 // ERROR10: 37:22: note: declared in 'Class2' | |
176 #endif |