summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-07-26 22:53:54 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-07-26 22:53:54 +0000
commitfff926670b94a8336c3a7fc45ca38a05b252c792 (patch)
treee6c162efbc843acb90d0e12cff16571a6d55dfa3 /clang/lib/Sema/SemaStmt.cpp
parent9ce0f779bc22f696eb1afbb6cc5095d8d2de0d50 (diff)
downloadbcm5719-llvm-fff926670b94a8336c3a7fc45ca38a05b252c792.tar.gz
bcm5719-llvm-fff926670b94a8336c3a7fc45ca38a05b252c792.zip
PR16708: If a lambda has an implicit return type, don't get confused if its return type has already been determined to be a type containing an 'auto'.
llvm-svn: 187266
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 5502a041d23..7feb96f6a64 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2368,23 +2368,8 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
// For blocks/lambdas with implicit return types, we check each return
// statement individually, and deduce the common return type when the block
// or lambda is completed.
- if (AutoType *AT =
- FnRetType.isNull() ? 0 : FnRetType->getContainedAutoType()) {
- // In C++1y, the return type may involve 'auto'.
- FunctionDecl *FD = cast<LambdaScopeInfo>(CurCap)->CallOperator;
- if (CurContext->isDependentContext()) {
- // C++1y [dcl.spec.auto]p12:
- // Return type deduction [...] occurs when the definition is
- // instantiated even if the function body contains a return
- // statement with a non-type-dependent operand.
- CurCap->ReturnType = FnRetType = Context.DependentTy;
- } else if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
- FD->setInvalidDecl();
- return StmtError();
- } else
- CurCap->ReturnType = FnRetType = FD->getResultType();
- } else if (CurCap->HasImplicitReturnType) {
- // FIXME: Fold this into the 'auto' codepath above.
+ if (CurCap->HasImplicitReturnType) {
+ // FIXME: Fold this into the 'auto' codepath below.
if (RetValExp && !isa<InitListExpr>(RetValExp)) {
ExprResult Result = DefaultFunctionArrayLvalueConversion(RetValExp);
if (Result.isInvalid())
@@ -2411,6 +2396,21 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
// make sure we provide a return type now for better error recovery.
if (CurCap->ReturnType.isNull())
CurCap->ReturnType = FnRetType;
+ } else if (AutoType *AT =
+ FnRetType.isNull() ? 0 : FnRetType->getContainedAutoType()) {
+ // In C++1y, the return type may involve 'auto'.
+ FunctionDecl *FD = cast<LambdaScopeInfo>(CurCap)->CallOperator;
+ if (CurContext->isDependentContext()) {
+ // C++1y [dcl.spec.auto]p12:
+ // Return type deduction [...] occurs when the definition is
+ // instantiated even if the function body contains a return
+ // statement with a non-type-dependent operand.
+ CurCap->ReturnType = FnRetType = Context.DependentTy;
+ } else if (DeduceFunctionTypeFromReturnExpr(FD, ReturnLoc, RetValExp, AT)) {
+ FD->setInvalidDecl();
+ return StmtError();
+ } else
+ CurCap->ReturnType = FnRetType = FD->getResultType();
}
assert(!FnRetType.isNull());
OpenPOWER on IntegriCloud