diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-01-09 05:10:55 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-01-09 05:10:55 +0000 |
commit | e01c466c679d939f09a4b1d9f65085f90bf40ea4 (patch) | |
tree | b347c32c4513f532e1ad12ac7bebcfddc0df16a2 /clang/lib/Parse/ParseExprCXX.cpp | |
parent | 76a4b95ad84a0fd23e34982cfb1b40b39ca2fb4d (diff) | |
download | bcm5719-llvm-e01c466c679d939f09a4b1d9f65085f90bf40ea4.tar.gz bcm5719-llvm-e01c466c679d939f09a4b1d9f65085f90bf40ea4.zip |
Parse: Don't crash when trailing return type is missing
Sema::CheckParmsForFunctionDef can't cope with a null TypeSourceInfo.
Don't let the AST contain the malformed lambda.
This fixes PR22122.
llvm-svn: 225505
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index f101d9f1273..355503caa9b 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1052,6 +1052,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth); Actions.PushLambdaScope(); + TypeResult TrailingReturnType; if (Tok.is(tok::l_paren)) { ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope | @@ -1112,7 +1113,6 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( SourceLocation FunLocalRangeEnd = DeclEndLoc; // Parse trailing-return-type[opt]. - TypeResult TrailingReturnType; if (Tok.is(tok::arrow)) { FunLocalRangeEnd = Tok.getLocation(); SourceRange Range; @@ -1182,12 +1182,11 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( MaybeParseCXX11Attributes(Attr, &DeclEndLoc); // Parse the return type, if there is one. - TypeResult TrailingReturnType; if (Tok.is(tok::arrow)) { SourceRange Range; TrailingReturnType = ParseTrailingReturnType(Range); if (Range.getEnd().isValid()) - DeclEndLoc = Range.getEnd(); + DeclEndLoc = Range.getEnd(); } SourceLocation NoLoc; @@ -1235,9 +1234,9 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( StmtResult Stmt(ParseCompoundStatementBody()); BodyScope.Exit(); - if (!Stmt.isInvalid()) + if (!Stmt.isInvalid() && !TrailingReturnType.isInvalid()) return Actions.ActOnLambdaExpr(LambdaBeginLoc, Stmt.get(), getCurScope()); - + Actions.ActOnLambdaError(LambdaBeginLoc, getCurScope()); return ExprError(); } |