Add better checking
authorChris Lattner <sabre@nondot.org>
Fri, 10 Oct 2003 03:56:01 +0000 (03:56 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 10 Oct 2003 03:56:01 +0000 (03:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8996 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/llvmAsmParser.y

index 773ea7a0f5f9eda0c3c984ba1ebe7e5775b2de8a..4543fcdc49c8a6403449c297f52f872ac81be2f4 100644 (file)
@@ -1060,6 +1060,9 @@ ConstVal : SIntType EINT64VAL {      // integral constants
 
 
 ConstExpr: CAST '(' ConstVal TO Types ')' {
+    if (!$5->get()->isFirstClassType())
+      ThrowException("cast constant expression to a non-primitive type: '" +
+                     $5->get()->getDescription() + "'!");
     $$ = ConstantExpr::getCast($3, $5->get());
     delete $5;
   }
@@ -1632,6 +1635,9 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     $$ = new ShiftInst($1, $2, $4);
   }
   | CAST ResolvedVal TO Types {
+    if (!$4->get()->isFirstClassType())
+      ThrowException("cast instruction to a non-primitive type: '" +
+                     $4->get()->getDescription() + "'!");
     $$ = new CastInst($2, *$4);
     delete $4;
   }