1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Add better checking

llvm-svn: 8996
This commit is contained in:
Chris Lattner 2003-10-10 03:56:01 +00:00
parent 3b63013cd0
commit e4012123b6

View File

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