Parse: Don't crash if missing an initializer expression

llvm-svn: 225768
This commit is contained in:
David Majnemer 2015-01-13 05:28:24 +00:00
parent 64e3dedf3b
commit 906ed278b9
2 changed files with 6 additions and 1 deletions

View File

@ -5625,13 +5625,14 @@ void Parser::ParseParameterDeclarationClause(
// FIXME: Can we use a smart pointer for Toks?
DefArgToks = new CachedTokens;
SourceLocation ArgStartLoc = NextToken().getLocation();
if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
delete DefArgToks;
DefArgToks = nullptr;
Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
} else {
Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
(*DefArgToks)[1].getLocation());
ArgStartLoc);
}
} else {
// Consume the '='.

View File

@ -36,3 +36,7 @@ struct T {
struct S {
void f(int &r = error); // expected-error {{use of undeclared identifier 'error'}}
};
struct U {
void i(int x = ) {} // expected-error{{expected expression}}
};