mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
Reject duplicate case values in a switch, PR5450.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a3da922a27
commit
d682a60c4e
@ -780,9 +780,13 @@ void Verifier::visitSwitchInst(SwitchInst &SI) {
|
|||||||
// Check to make sure that all of the constants in the switch instruction
|
// Check to make sure that all of the constants in the switch instruction
|
||||||
// have the same type as the switched-on value.
|
// have the same type as the switched-on value.
|
||||||
const Type *SwitchTy = SI.getCondition()->getType();
|
const Type *SwitchTy = SI.getCondition()->getType();
|
||||||
for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i)
|
SmallPtrSet<ConstantInt*, 32> Constants;
|
||||||
|
for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i) {
|
||||||
Assert1(SI.getCaseValue(i)->getType() == SwitchTy,
|
Assert1(SI.getCaseValue(i)->getType() == SwitchTy,
|
||||||
"Switch constants must all be same type as switch value!", &SI);
|
"Switch constants must all be same type as switch value!", &SI);
|
||||||
|
Assert2(Constants.insert(SI.getCaseValue(i)),
|
||||||
|
"Duplicate integer as switch case", &SI, SI.getCaseValue(i));
|
||||||
|
}
|
||||||
|
|
||||||
visitTerminatorInst(SI);
|
visitTerminatorInst(SI);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user