diff options
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 4 | ||||
-rw-r--r-- | test/Parser/cxx0x-decl.cpp | 8 |
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; } |