From: Richard Smith Date: Wed, 27 Aug 2014 03:23:12 +0000 (+0000) Subject: PR20760: Don't assert (and produce better diagnostics) if a default initializer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef86fa4d1f5e54e07cda89ca11e469676bdd57fa;p=clang PR20760: Don't assert (and produce better diagnostics) if a default initializer contains an unmatched closing bracket token. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216518 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 55caa5e59f..3571d5ab41 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -540,11 +540,13 @@ void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) { // The next token should be our artificial terminating EOF token. if (Tok.isNot(tok::eof)) { - SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation); - if (!EndLoc.isValid()) - EndLoc = Tok.getLocation(); - // No fixit; we can't recover as if there were a semicolon here. - Diag(EndLoc, diag::err_expected_semi_decl_list); + if (!Init.isInvalid()) { + SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation); + if (!EndLoc.isValid()) + EndLoc = Tok.getLocation(); + // No fixit; we can't recover as if there were a semicolon here. + Diag(EndLoc, diag::err_expected_semi_decl_list); + } // Consume tokens until we hit the artificial EOF. while (Tok.isNot(tok::eof)) @@ -891,11 +893,13 @@ private: /// ConsumeAndStoreInitializer - Consume and store the token at the passed token /// container until the end of the current initializer expression (either a /// default argument or an in-class initializer for a non-static data member). -/// The final token is not consumed. +/// +/// Returns \c true if we reached the end of something initializer-shaped, +/// \c false if we bailed out. bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, CachedInitKind CIK) { // We always want this function to consume at least one token if not at EOF. - bool IsFirstTokenConsumed = true; + bool IsFirstToken = true; // Number of possible unclosed