xref: /llvm-project/llvm/test/TableGen/code.td (revision 415fab6f67b4db59abe533130272d55b4efbf0cb)
18fb962c0SNicolai Haehnle// RUN: llvm-tblgen %s | FileCheck %s
2*415fab6fSPaul C. Anagnostopoulos// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
38fb962c0SNicolai Haehnle// XFAIL: vg_leak
48fb962c0SNicolai Haehnle
5*415fab6fSPaul C. Anagnostopoulos// CHECK: def A1
6*415fab6fSPaul C. Anagnostopoulos// CHECK:   code CodeCode = [{code here;}]
7*415fab6fSPaul C. Anagnostopoulos// CHECK:   code StringCode = [{code here;}]
88fb962c0SNicolai Haehnle
9*415fab6fSPaul C. Anagnostopoulos// CHECK: def A2
10*415fab6fSPaul C. Anagnostopoulos// CHECK:   string CodeCode = "string here"
11*415fab6fSPaul C. Anagnostopoulos// CHECK:   string StringCode = "string here"
128fb962c0SNicolai Haehnle
13*415fab6fSPaul C. Anagnostopoulos// CHECK: def B1
14*415fab6fSPaul C. Anagnostopoulos// CHECK:   string CodeCode = "with paste 7"
15*415fab6fSPaul C. Anagnostopoulos// CHECK:   string StringCode = "with paste 7"
16*415fab6fSPaul C. Anagnostopoulos
17*415fab6fSPaul C. Anagnostopoulos// CHECK: def C1
18*415fab6fSPaul C. Anagnostopoulos// CHECK:   code CodeCode = [{with concat 42}]
19*415fab6fSPaul C. Anagnostopoulos// CHECK:   code StringCode = [{with concat 42}]
20*415fab6fSPaul C. Anagnostopoulos
21*415fab6fSPaul C. Anagnostopoulos// CHECK: def D1
22*415fab6fSPaul C. Anagnostopoulos// CHECK:   code CodeCode = [{with concat 108!}]
23*415fab6fSPaul C. Anagnostopoulos// CHECK:   code StringCode = [{with concat 108!}]
248fb962c0SNicolai Haehnle
258fb962c0SNicolai Haehnleclass A<code c> {
26*415fab6fSPaul C. Anagnostopoulos  code CodeCode = c;
27*415fab6fSPaul C. Anagnostopoulos  string StringCode = c;
288fb962c0SNicolai Haehnle}
298fb962c0SNicolai Haehnle
30*415fab6fSPaul C. Anagnostopoulosdef A1 : A<[{code here;}]>;
31*415fab6fSPaul C. Anagnostopoulosdef A2 : A<"string here">;
328fb962c0SNicolai Haehnle
33*415fab6fSPaul C. Anagnostopoulosclass B<int i> : A<"with paste " # i>;
34*415fab6fSPaul C. Anagnostopoulosclass C<int i> : A<!strconcat([{with concat }], !cast<string>(i))>;
35*415fab6fSPaul C. Anagnostopoulosclass D<int i> : A<!strconcat([{with concat }], !cast<string>(i), "!")>;
368fb962c0SNicolai Haehnle
37*415fab6fSPaul C. Anagnostopoulosdef B1 : B<7>;
38*415fab6fSPaul C. Anagnostopoulosdef C1 : C<42>;
39*415fab6fSPaul C. Anagnostopoulosdef D1 : D<108>;
40*415fab6fSPaul C. Anagnostopoulos
41*415fab6fSPaul C. Anagnostopoulos#ifdef ERROR1
42*415fab6fSPaul C. Anagnostopoulos
43*415fab6fSPaul C. Anagnostopoulos// ERROR1: the 'code' type is not allowed
44*415fab6fSPaul C. Anagnostopoulos
45*415fab6fSPaul C. Anagnostopoulosdef Zerror1 {
46*415fab6fSPaul C. Anagnostopoulos  code Code = !cast<code>("i = 0;");
47*415fab6fSPaul C. Anagnostopoulos}
48*415fab6fSPaul C. Anagnostopoulos
49*415fab6fSPaul C. Anagnostopoulos#endif
50