]> granicus.if.org Git - clang/commitdiff
Replace a parser assertion with a warning, suggestion by Doug.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 9 Aug 2010 10:54:26 +0000 (10:54 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 9 Aug 2010 10:54:26 +0000 (10:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110568 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseCXXInlineMethods.cpp

index dbb54fbe42efcb181515d5cff0f44ff6b44e39ce..955f1ab1a5323d507d93ff73dae2f005f292078c 100644 (file)
@@ -271,6 +271,8 @@ def err_destructor_tilde_identifier : Error<
   "expected a class name after '~' to name a destructor">;
 def err_destructor_template_id : Error<
   "destructor name %0 does not refer to a template">;
+def warn_default_arg_unparsed : Warning<
+  "parsing of default argument is incomplete">;
 
 // C++ derived classes
 def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;
index 9f12ab501e43a8776614e017dd1d3cdc6a4494cf..8496ddd002501225d4301e842ad02a2f0eb9b4e0 100644 (file)
@@ -143,9 +143,14 @@ void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
         if (DefArgResult.isInvalid())
           Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
         else {
-          assert(Tok.is(tok::cxx_defaultarg_end) &&
-                 "We didn't parse the whole default arg!");
-          ConsumeToken(); // Consume tok::cxx_defaultarg_end.
+          if (Tok.is(tok::cxx_defaultarg_end))
+            ConsumeToken();
+          else {
+            // Warn that there are tokens from the default arg that we left
+            // unparsed. This actually indicates a bug in clang but we avoid
+            // asserting because we want the parser robust.
+            Diag(Tok.getLocation(), diag::warn_default_arg_unparsed);
+          }
           Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
                                             move(DefArgResult));
         }