aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-01-14 01:55:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-01-14 01:55:13 +0000
commit7b19cb116d0909de72dc8242b0a4e6c5ed39d421 (patch)
tree717d8de8c6a0918bd20d1cb3aaf2c4ccb24f9a16
parent05756dc8d11cd2054e0cb94f0302e4eb39acc68e (diff)
*this is const in a trailing-return-type for a constexpr member function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172375 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseDecl.cpp4
-rw-r--r--test/Parser/cxx0x-decl.cpp8
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index bd79e56b09..1fbe6b3a1a 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -4761,7 +4761,9 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
Actions.CurContext->isRecord()));
Sema::CXXThisScopeRAII ThisScope(Actions,
dyn_cast<CXXRecordDecl>(Actions.CurContext),
- DS.getTypeQualifiers(),
+ DS.getTypeQualifiers() |
+ (D.getDeclSpec().isConstexprSpecified()
+ ? Qualifiers::Const : 0),
IsCXX11MemberFunction);
// Parse exception-specification[opt].
diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp
index d74b337b31..1da7dd2833 100644
--- a/test/Parser/cxx0x-decl.cpp
+++ b/test/Parser/cxx0x-decl.cpp
@@ -41,3 +41,11 @@ struct SS {
};
using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}}
+
+// Ensure that 'this' has a const-qualified type in a trailing return type for
+// a constexpr function.
+struct ConstexprTrailingReturn {
+ int n;
+ constexpr auto f() -> decltype((n));
+};
+constexpr const int &ConstexprTrailingReturn::f() const { return n; }