Skip to content

Commit

Permalink
Merge pull request swiftlang#714 from ezephir/sr-304-undef-values
Browse files Browse the repository at this point in the history
[SIL] Add tests for 'undef' values & code fixes
  • Loading branch information
jckarter committed Mar 10, 2016
2 parents a3b8806 + 04b89d5 commit 78eb303
Show file tree
Hide file tree
Showing 2 changed files with 374 additions and 17 deletions.
17 changes: 10 additions & 7 deletions lib/SIL/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2546,15 +2546,18 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
SILValue casevalue;
SILValue result;
std::tie(casevalue, result) = I->getCase(i);
auto *il = dyn_cast<IntegerLiteralInst>(casevalue);
require(il,
"select_value case operands should refer to integer literals");
APInt elt = il->getValue();

if (!isa<SILUndef>(casevalue)) {
auto *il = dyn_cast<IntegerLiteralInst>(casevalue);
require(il,
"select_value case operands should refer to integer literals");
APInt elt = il->getValue();

require(!seenCaseValues.count(elt),
"select_value dispatches on same case value more than once");
require(!seenCaseValues.count(elt),
"select_value dispatches on same case value more than once");

seenCaseValues.insert(elt);
seenCaseValues.insert(elt);
}

requireSameType(I->getOperand()->getType(), casevalue->getType(),
"select_value case value must match type of operand");
Expand Down
Loading

0 comments on commit 78eb303

Please sign in to comment.