nested-name-specifier (as the standard appears to require), treat it as the
type specifier 'decltype(auto)' followed by a nested-name-specifier starting
with '::'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294506
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
}
}
}
+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 {