diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-26 23:45:07 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-26 23:45:07 +0000 |
commit | 1836e600234bc53bf0db60cbedc750ed635fd62d (patch) | |
tree | 08ce88c84901fe8f33e88a57767122103a97b632 /clang/lib/Sema/SemaStmt.cpp | |
parent | 3cf7eb50a9b9096f8a26ab2e232f1dd62b221a87 (diff) | |
download | bcm5719-llvm-1836e600234bc53bf0db60cbedc750ed635fd62d.tar.gz bcm5719-llvm-1836e600234bc53bf0db60cbedc750ed635fd62d.zip |
Handle a difference in lambda return type deduction between C++11 and C++1y: if
no return type is specified, C++11 will deduce a cv-qualified return type in
some cases, but C++1y never will.
llvm-svn: 187275
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 7feb96f6a64..61319d22389 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -2376,9 +2376,15 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { return StmtError(); RetValExp = Result.take(); - if (!CurContext->isDependentContext()) + if (!CurContext->isDependentContext()) { FnRetType = RetValExp->getType(); - else + // In C++11, we take the type of the expression after decay and + // lvalue-to-rvalue conversion, so a class type can be cv-qualified. + // In C++1y, we perform template argument deduction as if the return + // type were 'auto', so an implicit return type is never cv-qualified. + if (getLangOpts().CPlusPlus1y && FnRetType.hasQualifiers()) + FnRetType = FnRetType.getUnqualifiedType(); + } else FnRetType = CurCap->ReturnType = Context.DependentTy; } else { if (RetValExp) { |