summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-15 15:57:22 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-15 15:57:22 +0000
commitb9e38f19f78ea0416b276fa28922a6790415acd9 (patch)
tree8761be435c0ada77ccc3d6a92033c63b05e29151
parentd8c61785edb19ff4a0df8e06b4af65e7237ea3df (diff)
downloadbcm5719-llvm-b9e38f19f78ea0416b276fa28922a6790415acd9.tar.gz
bcm5719-llvm-b9e38f19f78ea0416b276fa28922a6790415acd9.zip
Specialize the diagnostic complaining about conflicting types of
return statements within a lambda; this diagnostic previously referred to blocks. llvm-svn: 150584
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--clang/lib/Sema/SemaStmt.cpp4
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0b6d7748662..e5bba692a00 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4142,8 +4142,8 @@ def err_typecheck_convert_incompatible : Error<
"%select{none|const|restrict|const and restrict|volatile|const and volatile|"
"volatile and restrict|const, volatile, and restrict}6)}4">;
def err_typecheck_missing_return_type_incompatible : Error<
- "return type %0 must match previous return type %1 when block"
- " literal has unspecified explicit return type">;
+ "return type %0 must match previous return type %1 when %select{block "
+ "literal|lambda expression}2 has unspecified explicit return type">;
def warn_incompatible_qualified_id : Warning<
"%select{assigning to|passing|returning|converting|initializing|sending|casting}2"
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index b47e3d29d17..4351e9ba101 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1847,9 +1847,9 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
!CurCap->ReturnType->isDependentType() &&
!ReturnT->isDependentType() &&
!Context.hasSameType(ReturnT, CurCap->ReturnType)) {
- // FIXME: Adapt diagnostic for lambdas.
Diag(ReturnLoc, diag::err_typecheck_missing_return_type_incompatible)
- << ReturnT << CurCap->ReturnType;
+ << ReturnT << CurCap->ReturnType
+ << getCurLambda() != 0;
return StmtError();
}
CurCap->ReturnType = ReturnT;
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
index 586825f0531..d816e1702a6 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
@@ -37,8 +37,8 @@ X infer_X_return_type_fail(X x) {
return [x](int y) { // expected-warning{{omitted result type}}
if (y > 0)
return X();
- else // FIXME: shouldn't mention blocks
- return x; // expected-error{{return type 'const X' must match previous return type 'X' when block literal has unspecified explicit return type}}
+ else
+ return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
}(5);
}
OpenPOWER on IntegriCloud