@@ -169,14 +169,18 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
169169 // Find the record of the base class subobjects for this type.
170170 QualType BaseType =
171171 Context.getCanonicalType (BaseSpec.getType ()).getUnqualifiedType ();
172+ bool isCurrentInstantiation = false ;
173+ if (auto *TST = BaseSpec.getType ()->getAs <TemplateSpecializationType>())
174+ isCurrentInstantiation = TST->isCurrentInstantiation ();
172175
173176 // C++ [temp.dep]p3:
174177 // In the definition of a class template or a member of a class template,
175178 // if a base class of the class template depends on a template-parameter,
176179 // the base class scope is not examined during unqualified name lookup
177180 // either at the point of definition of the class template or member or
178181 // during an instantiation of the class tem- plate or member.
179- if (!LookupInDependent && BaseType->isDependentType ())
182+ if (!LookupInDependent &&
183+ (BaseType->isDependentType () && !isCurrentInstantiation))
180184 continue ;
181185
182186 // Determine whether we need to visit this base class at all,
@@ -244,9 +248,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
244248 return FoundPath;
245249 }
246250 } else if (VisitBase) {
247- CXXRecordDecl *BaseRecord;
251+ CXXRecordDecl *BaseRecord = nullptr ;
248252 if (LookupInDependent) {
249- BaseRecord = nullptr ;
250253 const TemplateSpecializationType *TST =
251254 BaseSpec.getType ()->getAs <TemplateSpecializationType>();
252255 if (!TST) {
@@ -265,8 +268,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
265268 BaseRecord = nullptr ;
266269 }
267270 } else {
268- BaseRecord = cast<CXXRecordDecl>(
269- BaseSpec. getType ()-> castAs <RecordType>() ->getDecl ());
271+ if ( auto *RT = BaseSpec. getType ()-> getAs <RecordType>())
272+ BaseRecord = cast<CXXRecordDecl>(RT ->getDecl ());
270273 }
271274 if (BaseRecord &&
272275 lookupInBases (Context, BaseRecord, BaseMatches, LookupInDependent)) {
0 commit comments