]> granicus.if.org Git - clang/commitdiff
Specialize the diagnostic complaining about conflicting types of
authorDouglas Gregor <dgregor@apple.com>
Wed, 15 Feb 2012 15:57:22 +0000 (15:57 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 15 Feb 2012 15:57:22 +0000 (15:57 +0000)
return statements within a lambda; this diagnostic previously referred
to blocks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150584 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaStmt.cpp
test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp

index 0b6d7748662fbde8d0b427a5db9e2dc4c6db3dbc..e5bba692a0071d1a097d2a3e434bf81d4b1a120a 100644 (file)
@@ -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"
index b47e3d29d179d9737b83b16eb6bb2826d57462cb..4351e9ba10153a96696b6a270d487bccb3644b7d 100644 (file)
@@ -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;
index 586825f0531be4699158f182f74a0da9bb10df58..d816e1702a6da8b131c119d22b6573d5c1bad279 100644 (file)
@@ -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);
 }