brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 5c0093a Raw
93 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s3// RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s4 5// Test at top level.6 7// CHECK-NOT: def aNo8// CHECK: def aYes9if 0 then def aNo;10if 1 then def aYes;11 12// Test inside a foreach, with condition based on the iteration variable.13 14// CHECK: def bNotThree115// CHECK: def bNotThree216// CHECK: def bNotThree417// CHECK: def bThree318foreach i = 1...4 in {19  if !eq(i, 3) then {20    def "bThree" # i;21  } else {22    def "bNotThree" # i;23  }24}25 26// Test inside a multiclass, with condition based on a multiclass parameter.27 28multiclass Multi<int i> {29  def Unconditional;30 31  if !eq(i, 2) then32    def Cond;33 34  if !ge(i, 3) then35    def ThenRec;36  else37    def ElseRec;38}39 40// CHECK-NOT: def c1Cond41// CHECK: def c1ElseRec42// CHECK-NOT: def c1ThenRec43// CHECK: def c1Unconditional44defm c1: Multi<1>;45 46// CHECK: def c2Cond47// CHECK: def c2ElseRec48// CHECK-NOT: def c2ThenRec49// CHECK: def c2Unconditional50defm c2: Multi<2>;51 52// CHECK-NOT: def c3Cond53// CHECK-NOT: def c3ElseRec54// CHECK: def c3ThenRec55// CHECK: def c3Unconditional56defm c3: Multi<3>;57 58// Test resolution of the dangling-else ambiguity.59 60// CHECK: def dThenElse0061// CHECK-NOT: def dThenElse162// CHECK-NOT: def dThenElse1163// CHECK: def dThenThen0164foreach i = 0...1 in65  foreach j = 0...1 in66    if !eq(i,0) then67      if !eq(j,1) then68        def "dThenThen"#i#j;69      else // binds to the inner if, not the outer one70        def "dThenElse"#i#j;71 72// Error tests: ensure you can't put an if inside a def or class.73 74#ifdef ERROR175def baddef {76  int x = 3;77  // ERROR1: [[@LINE+1]]:3: error: Unknown token when expecting a type78  if 1 then {79    int y = 4;80  }81}82#endif83 84#ifdef ERROR285class badclass<int i> {86  int x = 3;87  // ERROR2: [[@LINE+1]]:3: error: Unknown token when expecting a type88  if !eq(i, 5) then {89    int y = 4;90  }91}92#endif93