More APSInt appeasement

llvm-svn: 62884
This commit is contained in:
Douglas Gregor 2009-01-23 22:22:29 +00:00
parent 486d309b34
commit 7a95b08fce
2 changed files with 21 additions and 13 deletions

View File

@ -671,18 +671,26 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
if (CheckArrayDesignatorExpr(*this, StartIndex, StartValue) ||
CheckArrayDesignatorExpr(*this, EndIndex, EndValue))
Invalid = true;
else if (EndValue < StartValue) {
Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range)
<< StartValue.toString(10) << EndValue.toString(10)
<< StartIndex->getSourceRange() << EndIndex->getSourceRange();
Invalid = true;
} else {
Designators.push_back(ASTDesignator(InitExpressions.size(),
D.getLBracketLoc(),
D.getEllipsisLoc(),
D.getRBracketLoc()));
InitExpressions.push_back(StartIndex);
InitExpressions.push_back(EndIndex);
else {
// Make sure we're comparing values with the same bit width.
if (StartValue.getBitWidth() > EndValue.getBitWidth())
EndValue.extend(StartValue.getBitWidth());
else if (StartValue.getBitWidth() < EndValue.getBitWidth())
StartValue.extend(EndValue.getBitWidth());
if (EndValue < StartValue) {
Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range)
<< StartValue.toString(10) << EndValue.toString(10)
<< StartIndex->getSourceRange() << EndIndex->getSourceRange();
Invalid = true;
} else {
Designators.push_back(ASTDesignator(InitExpressions.size(),
D.getLBracketLoc(),
D.getEllipsisLoc(),
D.getRBracketLoc()));
InitExpressions.push_back(StartIndex);
InitExpressions.push_back(EndIndex);
}
}
break;
}

View File

@ -1,4 +1,4 @@
// RUN: clang -fsyntax-only -verify %s
// RUN: clang -fsyntax-only -verify -arch x86_64 %s
int complete_array_from_init[] = { 1, 2, [10] = 5, 1, 2, [5] = 2, 6 };