71 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// RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s5// RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s6// RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s7 8class Class<int v> {9 int value = v;10}11 12deftype StringAlias = string;13deftype CodeAlias = code;14deftype DagAlias = dag;15deftype Boolean = bit;16deftype Byte = bits<8>;17deftype Integer = int;18deftype IntList = list<int>;19deftype ByteList = list<Byte>;20deftype ClassList = list<Class>;21// The type can be another type alias.22deftype ClassListAlias = ClassList;23 24// CHECK: def test {25// CHECK-NEXT: string str = "string";26// CHECK-NEXT: string codeStr = "code";27// CHECK-NEXT: dag dagExpr = ("string" "code");28// CHECK-NEXT: bit bool = 0;29// CHECK-NEXT: bits<8> byte = { 0, 1, 1, 1, 1, 0, 1, 1 };30// CHECK-NEXT: int integer = 123;31// CHECK-NEXT: list<int> ints = [1, 2, 3];32// CHECK-NEXT: list<bits<8>> bytes = [{ 0, 0, 0, 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 1, 1 }];33// CHECK-NEXT: list<Class> defs = [anonymous_0, anonymous_1, anonymous_2];34// CHECK-NEXT: }35def test {36 StringAlias str = "string";37 CodeAlias codeStr = "code";38 DagAlias dagExpr = (str codeStr);39 Boolean bool = false;40 Byte byte = 123;41 Integer integer = 123;42 IntList ints = [1, 2, 3];43 ByteList bytes = [1, 2, 3];44 ClassListAlias defs = [Class<1>, Class<2>, Class<3>];45}46 47#ifdef ERROR148// ERROR1: [[@LINE+1]]:9: error: type of this name 'Byte' already exists49deftype Byte = bits<8>;50#endif51 52#ifdef ERROR253// ERROR2: [[@LINE+1]]:9: error: type of this name 'Class' already exists54deftype Class = int;55#endif56 57#ifdef ERROR358// ERROR3: [[@LINE+1]]:22: error: cannot define type alias for class type 'Class'59deftype ClassAlias = Class;60#endif61 62#ifdef ERROR463// ERROR4: [[@LINE+1]]:7: error: there is already a defined type alias 'Byte'64class Byte; // incomplete class definition.65#endif66 67#ifdef ERROR568// ERROR5: [[@LINE+1]]:7: error: there is already a defined type alias 'Byte'69class Byte {}70#endif71