summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp5
-rw-r--r--clang/test/SemaCXX/cxx1y-deduced-return-type.cpp12
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 1ba1695800f..cb42a88e82b 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -216,7 +216,10 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
SourceLocation EndLoc = ParseDecltypeSpecifier(DS);
SourceLocation CCLoc;
- if (!TryConsumeToken(tok::coloncolon, CCLoc)) {
+ // Work around a standard defect: 'decltype(auto)::' is not a
+ // nested-name-specifier.
+ if (DS.getTypeSpecType() == DeclSpec::TST_decltype_auto ||
+ !TryConsumeToken(tok::coloncolon, CCLoc)) {
AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
return false;
}
diff --git a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
index 593ec48b439..a061cf4ddb7 100644
--- a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
+++ b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
@@ -385,6 +385,18 @@ namespace MemberTemplatesWithDeduction {
}
}
+namespace NNS {
+ int n;
+ decltype(auto) i();
+ decltype(n) j();
+ struct X {
+ // We resolve a wording bug here: 'decltype(auto)::' should not be parsed
+ // as a nested-name-specifier.
+ friend decltype(auto) ::NNS::i();
+ friend decltype(n) ::NNS::j(); // expected-error {{not a class}}
+ };
+}
+
namespace CurrentInstantiation {
// PR16875
template<typename T> struct S {
OpenPOWER on IntegriCloud