Home | History | Annotate | Download | only in TableGen
      1 // RUN: llvm-tblgen %s | FileCheck %s
      2 // XFAIL: vg_leak
      3 
      4 class A<int k, bits<2> x = 1> {
      5   int K = k;
      6   bits<2> Bits = x;
      7 }
      8 
      9 // CHECK: def a1
     10 // CHECK: Bits = { 0, 1 }
     11 def a1 : A<12>;
     12 
     13 // CHECK: def a2
     14 // CHECK: Bits = { 1, 0 }
     15 def a2 : A<13, 2>;
     16 
     17 // Here was the bug: X.Bits would get resolved to the default a1.Bits while
     18 // resolving the first template argument. When the second template argument
     19 // was processed, X would be set correctly, but Bits retained the default
     20 // value.
     21 class B<int k, A x = a1> {
     22   A X = x;
     23   bits<2> Bits = X.Bits;
     24 }
     25 
     26 // CHECK: def b1
     27 // CHECK: Bits = { 0, 1 }
     28 def b1 : B<27>;
     29 
     30 // CHECK: def b2
     31 // CHECK: Bits = { 1, 0 }
     32 def b2 : B<28, a2>;
     33 
     34 class C<A x = a1> {
     35   bits<2> Bits = x.Bits;
     36 }
     37 
     38 // CHECK: def c1
     39 // CHECK: Bits = { 0, 1 }
     40 def c1 : C;
     41 
     42 // CHECK: def c2
     43 // CHECK: Bits = { 1, 0 }
     44 def c2 : C<a2>;
     45