summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/TableGen/cast-typeerror.td2
-rw-r--r--llvm/test/TableGen/self-reference.td31
2 files changed, 32 insertions, 1 deletions
diff --git a/llvm/test/TableGen/cast-typeerror.td b/llvm/test/TableGen/cast-typeerror.td
index 4cda44b2431..af33a01d27e 100644
--- a/llvm/test/TableGen/cast-typeerror.td
+++ b/llvm/test/TableGen/cast-typeerror.td
@@ -10,5 +10,5 @@ class C<string name> {
B b = !cast<B>(name);
}
-// CHECK: error: Invalid value of type 'A' is found when setting 'b' of type 'B'
+// CHECK: error: Expected type 'B', got 'A' in: !cast<B>("A0")
def Test : C<"A0">;
diff --git a/llvm/test/TableGen/self-reference.td b/llvm/test/TableGen/self-reference.td
index a4f1d9a0737..89d72343047 100644
--- a/llvm/test/TableGen/self-reference.td
+++ b/llvm/test/TableGen/self-reference.td
@@ -16,6 +16,14 @@
// CHECK: dag q = (ops C0);
// CHECK: }
+// CHECK: def D0 {
+// CHECK: D d = D0;
+// CHECK: }
+
+// CHECK: def E0 {
+// CHECK: E e = E0;
+// CHECK: }
+
def ops;
class A<dag d> {
@@ -42,3 +50,26 @@ class C<string self> {
}
def C0 : C<"C0">;
+
+// Explore some unused corner cases.
+//
+// A self-reference within a class may seem icky, but it unavoidably falls out
+// orthogonally of having forward class declarations and late resolve of self
+// references.
+class D<string self> {
+ D d = !cast<D>(self);
+}
+
+def D0 : D<"D0">;
+
+class E<E x> {
+ E e = x;
+}
+
+// Putting the !cast directly in the def should work as well: we shouldn't
+// depend on implementation details of when exactly the record is looked up.
+//
+// Note the difference between !cast<E>("E0") and plain E0: the latter wouldn't
+// work here because E0 does not yet have E as a superclass while the template
+// arguments are being parsed.
+def E0 : E<!cast<E>("E0")>;
OpenPOWER on IntegriCloud