summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-20 04:00:21 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-20 04:00:21 +0000
commit0f8ede1654d3779583232a624346f24fd22b22f4 (patch)
treeb08623b96c13ea9c1bd6f4c94791b45ac71de980 /clang/lib
parenta379b181733b7ce77c9f336fd99e208d7c2a6f21 (diff)
downloadbcm5719-llvm-0f8ede1654d3779583232a624346f24fd22b22f4.tar.gz
bcm5719-llvm-0f8ede1654d3779583232a624346f24fd22b22f4.zip
Revert r146766, and add a testcase for which it introduced a wrong-code bug.
llvm-svn: 146961
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaInit.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 18fd3876e7f..7dbf8304315 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -171,9 +171,6 @@ class InitListChecker {
bool hadError;
bool VerifyOnly; // no diagnostics, no structure building
bool AllowBraceElision;
- Expr *LastCheckedSubobject;
- unsigned LastCheckedSubobjectIndex;
-
std::map<InitListExpr *, InitListExpr *> SyntacticToSemantic;
InitListExpr *FullyStructuredList;
@@ -473,8 +470,7 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity,
InitListChecker::InitListChecker(Sema &S, const InitializedEntity &Entity,
InitListExpr *IL, QualType &T,
bool VerifyOnly, bool AllowBraceElision)
- : SemaRef(S), VerifyOnly(VerifyOnly), AllowBraceElision(AllowBraceElision),
- LastCheckedSubobject(0), LastCheckedSubobjectIndex(0) {
+ : SemaRef(S), VerifyOnly(VerifyOnly), AllowBraceElision(AllowBraceElision) {
hadError = false;
unsigned newIndex = 0;
@@ -796,40 +792,13 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
if (Seq) {
if (!VerifyOnly) {
- // struct S {
- // S(int);
- // };
- //
- // S s[] = { [0 ... 2] = 3 };
- //
- // In code like this, we want to perform the initialization and then
- // update the syntactic list with the result. However, we reach this
- // point once for each subobject, but the update needs
- // to be done only once for each syntactic element. For this reason,
- // the initialization result and its syntactic Index are cached in
- // LastCheckedSubobject and LastCheckedSubobjectIndex and reused until
- // we move to the next Index.
- Expr *ResultExpr = LastCheckedSubobject;
-
- if (!ResultExpr || Index != LastCheckedSubobjectIndex) {
- ExprResult Result = Seq.Perform(SemaRef, Entity, Kind, MultiExprArg(&expr, 1));
-
- if (Result.isInvalid()) {
- hadError = true;
- ResultExpr = 0;
- } else {
- ResultExpr = Result.takeAs<Expr>();
- }
-
- LastCheckedSubobject = ResultExpr;
- LastCheckedSubobjectIndex = Index;
- }
-
- // Update the syntactic list
- IList->setInit(Index, ResultExpr);
+ ExprResult Result =
+ Seq.Perform(SemaRef, Entity, Kind, MultiExprArg(&expr, 1));
+ if (Result.isInvalid())
+ hadError = true;
UpdateStructuredListElement(StructuredList, StructuredIndex,
- ResultExpr);
+ Result.takeAs<Expr>());
}
++Index;
return;
OpenPOWER on IntegriCloud