Author: rsmith Date: Fri Jun 22 12:50:19 2018 New Revision: 335381 URL: http://llvm.org/viewvc/llvm-project?rev=335381&view=rev Log: Restore pre-r335182 behavior for naming inherited constructors as members of dependent contexts.
This permits cases where the names before and after the '::' in a dependent inherited constructor using-declaration do not match, but where we can nonetheless tell when parsing the template that a constructor is being named. Under (open) core language DR 2070, such cases will probably be ill-formed, but r335182 does not quite give that result and didn't intend to change this, so restore the old behavior for now. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=335381&r1=335380&r2=335381&view=diff ============================================================================== --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Fri Jun 22 12:50:19 2018 @@ -4985,7 +4985,8 @@ public: IdentifierInfo &Name); ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, - Scope *S, CXXScopeSpec &SS); + Scope *S, CXXScopeSpec &SS, + bool EnteringContext); ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=335381&r1=335380&r2=335381&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Jun 22 12:50:19 2018 @@ -2505,7 +2505,8 @@ bool Parser::ParseUnqualifiedId(CXXScope if (AllowConstructorName && Actions.isCurrentClassName(*Id, getCurScope(), &SS)) { // We have parsed a constructor name. - ParsedType Ty = Actions.getConstructorName(*Id, IdLoc, getCurScope(), SS); + ParsedType Ty = Actions.getConstructorName(*Id, IdLoc, getCurScope(), SS, + EnteringContext); if (!Ty) return true; Result.setConstructorName(Ty, IdLoc, IdLoc); @@ -2555,7 +2556,8 @@ bool Parser::ParseUnqualifiedId(CXXScope << FixItHint::CreateRemoval( SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)); ParsedType Ty = Actions.getConstructorName( - *TemplateId->Name, TemplateId->TemplateNameLoc, getCurScope(), SS); + *TemplateId->Name, TemplateId->TemplateNameLoc, getCurScope(), SS, + EnteringContext); if (!Ty) return true; Result.setConstructorName(Ty, TemplateId->TemplateNameLoc, Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=335381&r1=335380&r2=335381&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 22 12:50:19 2018 @@ -82,11 +82,20 @@ ParsedType Sema::getInheritingConstructo ParsedType Sema::getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, - Scope *S, CXXScopeSpec &SS) { + Scope *S, CXXScopeSpec &SS, + bool EnteringContext) { CXXRecordDecl *CurClass = getCurrentClass(S, &SS); assert(CurClass && &II == CurClass->getIdentifier() && "not a constructor name"); + // When naming a constructor as a member of a dependent context (eg, in a + // friend declaration or an inherited constructor declaration), form an + // unresolved "typename" type. + if (CurClass->isDependentContext() && !EnteringContext) { + QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), &II); + return ParsedType::make(T); + } + if (SS.isNotEmpty() && RequireCompleteDeclContext(SS, CurClass)) return ParsedType(); Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp?rev=335381&r1=335380&r2=335381&view=diff ============================================================================== --- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp (original) +++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Fri Jun 22 12:50:19 2018 @@ -199,5 +199,20 @@ namespace InhCtor { using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} }; UsingIntTemplate<int> uit; // expected-note {{here}} + + // This case is odd: we don't name the constructor of a dependent base as + // Base::Base, but we still happen to have enough information to identify + // when parsing the template that we're inheriting constructors. + // + // FIXME: Once CWG 2070 is resolved, check whether this case should be + // accepted or not. + namespace DependentCtorName { + template <typename T> struct B { B(int); }; + template <typename T> struct A : B<T> { + using X = B<T>; + using X::B; + }; + A<int> ab = 0; + } #endif } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits