DR1048: drop top-level cv-qualifiers when deducing the return type of a
lambda-expression in C++11, to match the C++14 rules.
llvm-svn: 224620
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index a3fd6fa..f487752 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2652,8 +2652,12 @@
return StmtError();
RetValExp = Result.get();
+ // DR1048: even prior to C++14, we should use the 'auto' deduction rules
+ // when deducing a return type for a lambda-expression (or by extension
+ // for a block). These rules differ from the stated C++11 rules only in
+ // that they remove top-level cv-qualifiers.
if (!CurContext->isDependentContext())
- FnRetType = RetValExp->getType();
+ FnRetType = RetValExp->getType().getUnqualifiedType();
else
FnRetType = CurCap->ReturnType = Context.DependentTy;
} else {