1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
3 // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
4 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s
6 // !setop and !getop are deprecated in favor of !setdagop and !getdagop.
7 // Two tests retain the old names just to be sure they are still supported.
17 dag orig = (foo 1, 2:$a, $b);
18 dag another = (qux "hello", $world);
20 // CHECK: dag replaceWithBar = (bar 1, 2:$a, ?:$b);
21 dag replaceWithBar = !setop(orig, bar);
23 // CHECK: dag replaceWithBaz = (qux 1, 2:$a, ?:$b);
24 dag replaceWithBaz = !setdagop(orig, qux);
26 // CHECK: Base getopWithCast = foo;
27 Base getopWithCast = !getop<Base>(orig);
29 // CHECK: dag getopToSetop = (foo "hello", ?:$world);
30 dag getopToSetop = !setdagop(another, !getdagop(orig));
32 // CHECK: dag getopToBangDag = (foo 1:$a, 2:$b, 3:$c);
33 dag getopToBangDag = !dag(!getdagop(orig), [1, 2, 3], ["a", "b", "c"]);
35 // CHECK: dag getopToDagInit = (foo "it worked");
36 dag getopToDagInit = (!getdagop(orig) "it worked");
39 // !getdagop(...) has a static type of 'any record at all, with no
40 // required superclasses'. That's too general to use in an
41 // assignment whose LHS demands an instance of Base, so we expect a
42 // static (parse-time) type-checking error.
44 // ERROR1: error: Field 'noCast' of type 'Base' is incompatible with value '!getdagop(orig)' of type '{}'
45 Base noCast = !getdagop(orig);
49 // Here, we expect a _dynamic_ type error, when it turns out at
50 // evaluation time that the operator of 'another' is a record that
51 // isn't an instance of the specified base class.
53 // ERROR2: error: Expected type 'Base', got 'OtherBase' in: !getdagop((qux "hello", ?:$world))
54 Base badCast = !getdagop<Base>(another);
58 // Obviously, you shouldn't be able to give any type to !getdagop that
59 // isn't a class type.
61 // ERROR3: error: type for !getdagop must be a record type
62 int ridiculousCast = !getdagop<int>(orig);