diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-03 09:28:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-03 09:28:22 +0000 |
commit | e2f56196e916e4d2f9eeec5c8978490cdedb3f64 (patch) | |
tree | 460c39d1e870bc918e8dfe4cf896984e88ce0b8a /lib/Parse/ParseInit.cpp | |
parent | 86cd8afb03dea4c2e5011bd1866fa9eebf3c001f (diff) |
Fix PR3001: if we have an error parsing an initializer, make sure to remove
the designator corresponding to it, otherwise Sema and later parsing will
get confused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseInit.cpp')
-rw-r--r-- | lib/Parse/ParseInit.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index 82a33c21da..9b488566a6 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -263,10 +263,18 @@ Parser::ExprResult Parser::ParseBraceInitializer() { ExprResult SubElt; if (!MayBeDesignationStart(Tok.getKind(), PP)) SubElt = ParseInitializer(); - else + else { SubElt = ParseInitializerWithPotentialDesignator(InitExprDesignations, InitExprs.size()); - + + // If we had an erroneous initializer, and we had a potentially valid + // designator, make sure to remove the designator from + // InitExprDesignations, otherwise we'll end up with a designator with no + // making initializer. + if (SubElt.isInvalid) + InitExprDesignations.EraseDesignation(InitExprs.size()); + } + // If we couldn't parse the subelement, bail out. if (!SubElt.isInvalid) { InitExprs.push_back(SubElt.Val); |