mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
For PR1117:
Make the assembler generate a nice error message if a bad cast instruction is attempted instead of asserting out. This is made possible by the recently exposed method CastInst::castIsValid() which checks the validity of any cast instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33283 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0a11af1f73
commit
93947c3985
@ -1708,14 +1708,12 @@ ConstExpr: CastOps '(' ConstVal TO Types ')' {
|
||||
if (!UpRefs.empty())
|
||||
GEN_ERROR("Invalid upreference in type: " + (*$5)->getDescription());
|
||||
Constant *Val = $3;
|
||||
const Type *Ty = $5->get();
|
||||
if (!Val->getType()->isFirstClassType())
|
||||
GEN_ERROR("cast constant expression from a non-primitive type: '" +
|
||||
Val->getType()->getDescription() + "'!");
|
||||
if (!Ty->isFirstClassType())
|
||||
GEN_ERROR("cast constant expression to a non-primitive type: '" +
|
||||
Ty->getDescription() + "'!");
|
||||
$$ = ConstantExpr::getCast($1, $3, $5->get());
|
||||
const Type *DestTy = $5->get();
|
||||
if (!CastInst::castIsValid($1, $3, DestTy))
|
||||
GEN_ERROR("invalid cast opcode for cast from '" +
|
||||
Val->getType()->getDescription() + "' to '" +
|
||||
DestTy->getDescription() + "'!");
|
||||
$$ = ConstantExpr::getCast($1, $3, DestTy);
|
||||
delete $5;
|
||||
}
|
||||
| GETELEMENTPTR '(' ConstVal IndexList ')' {
|
||||
@ -2647,13 +2645,12 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
||||
if (!UpRefs.empty())
|
||||
GEN_ERROR("Invalid upreference in type: " + (*$4)->getDescription());
|
||||
Value* Val = $2;
|
||||
const Type* Ty = $4->get();
|
||||
if (!Val->getType()->isFirstClassType())
|
||||
GEN_ERROR("cast from a non-primitive type: '" +
|
||||
Val->getType()->getDescription() + "'!");
|
||||
if (!Ty->isFirstClassType())
|
||||
GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
|
||||
$$ = CastInst::create($1, Val, $4->get());
|
||||
const Type* DestTy = $4->get();
|
||||
if (!CastInst::castIsValid($1, Val, DestTy))
|
||||
GEN_ERROR("invalid cast opcode for cast from '" +
|
||||
Val->getType()->getDescription() + "' to '" +
|
||||
DestTy->getDescription() + "'!");
|
||||
$$ = CastInst::create($1, Val, DestTy);
|
||||
delete $4;
|
||||
}
|
||||
| SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
|
||||
|
Loading…
Reference in New Issue
Block a user