summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLambda.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-12-19 22:10:51 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-12-19 22:10:51 +0000
commit5a0e50cd87840b9f326e88d3b35c04c3c3b4c76b (patch)
tree6fc3634d210ee2245b5f77302dea00b2402bc870 /clang/lib/Sema/SemaLambda.cpp
parent86a7f7154987ccb1a09fd399162694e120a427a7 (diff)
downloadbcm5719-llvm-5a0e50cd87840b9f326e88d3b35c04c3c3b4c76b.tar.gz
bcm5719-llvm-5a0e50cd87840b9f326e88d3b35c04c3c3b4c76b.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r--clang/lib/Sema/SemaLambda.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index a64a0fb323d..90a81f4ec45 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -617,7 +617,7 @@ void Sema::deduceClosureReturnType(CapturingScopeInfo &CSI) {
// If it was ever a placeholder, it had to been deduced to DependentTy.
assert(CSI.ReturnType.isNull() || !CSI.ReturnType->isUndeducedType());
- // C++ Core Issue #975, proposed resolution:
+ // C++ core issue 975:
// If a lambda-expression does not include a trailing-return-type,
// it is as if the trailing-return-type denotes the following type:
// - if there are no return statements in the compound-statement,
@@ -631,6 +631,10 @@ void Sema::deduceClosureReturnType(CapturingScopeInfo &CSI) {
// same, that common type;
// - otherwise, the program is ill-formed.
//
+ // C++ core issue 1048 additionally removes top-level cv-qualifiers
+ // from the types of returned expressions to match the C++14 auto
+ // deduction rules.
+ //
// In addition, in blocks in non-C++ modes, if all of the return
// statements are enumerator-like expressions of some type T, where
// T has a name for linkage, then we infer the return type of the
@@ -679,7 +683,8 @@ void Sema::deduceClosureReturnType(CapturingScopeInfo &CSI) {
const ReturnStmt *RS = *I;
const Expr *RetE = RS->getRetValue();
- QualType ReturnType = (RetE ? RetE->getType() : Context.VoidTy);
+ QualType ReturnType =
+ (RetE ? RetE->getType() : Context.VoidTy).getUnqualifiedType();
if (Context.hasSameType(ReturnType, CSI.ReturnType))
continue;
OpenPOWER on IntegriCloud