Parse: Don't crash if missing an initializer expression
llvm-svn: 225768
This commit is contained in:
parent
64e3dedf3b
commit
906ed278b9
|
@ -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 '='.
|
||||
|
|
|
@ -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}}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue