aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-09 18:40:39 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-09 18:40:39 +0000
commita0c2b21e0d84ad289781e08e14148da6b8b8b76d (patch)
tree065ea6b8a45924ca2fb279ba0c6488b054fc0aca /lib/Sema/SemaStmt.cpp
parent8e4bc1ec61f5895d10dba3e6212d6b505c8caca7 (diff)
Don't allow deduction of a lambda result type from an initializer
list; it is not an expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150194 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index e49bcfada6..0adfb94800 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -1798,7 +1798,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
CapturingScopeInfo *CurCap = cast<CapturingScopeInfo>(getCurFunction());
if (CurCap->HasImplicitReturnType) {
QualType ReturnT;
- if (RetValExp) {
+ if (RetValExp && !isa<InitListExpr>(RetValExp)) {
ExprResult Result = DefaultFunctionArrayLvalueConversion(RetValExp);
if (Result.isInvalid())
return StmtError();
@@ -1808,7 +1808,15 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
ReturnT = RetValExp->getType();
else
ReturnT = Context.DependentTy;
- } else {
+ } else {
+ if (RetValExp) {
+ // C++11 [expr.lambda.prim]p4 bans inferring the result from an
+ // initializer list, because it is not an expression (even
+ // though we represent it as one). We still deduce 'void'.
+ Diag(ReturnLoc, diag::err_lambda_return_init_list)
+ << RetValExp->getSourceRange();
+ }
+
ReturnT = Context.VoidTy;
}
// We require the return types to strictly match here.