Replace a parser assertion with a warning, suggestion by Doug.

llvm-svn: 110568
This commit is contained in:
Argyrios Kyrtzidis 2010-08-09 10:54:26 +00:00
parent 13257c5527
commit 773894ccec
2 changed files with 10 additions and 3 deletions

View 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">;

View 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));
}