@@ -170,13 +170,19 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
170170 QualType BaseType =
171171 Context.getCanonicalType (BaseSpec.getType ()).getUnqualifiedType ();
172172
173+ bool isCurrentInstantiation = false ;
174+ if (auto *BaseRecord =
175+ cast<CXXRecordDecl>(BaseSpec.getType ()->getAsRecordDecl ()))
176+ isCurrentInstantiation = BaseRecord->isDependentContext () &&
177+ BaseRecord->isCurrentInstantiation (Record);
173178 // C++ [temp.dep]p3:
174179 // In the definition of a class template or a member of a class template,
175180 // if a base class of the class template depends on a template-parameter,
176181 // the base class scope is not examined during unqualified name lookup
177182 // either at the point of definition of the class template or member or
178183 // during an instantiation of the class tem- plate or member.
179- if (!LookupInDependent && BaseType->isDependentType ())
184+ if (!LookupInDependent &&
185+ (BaseType->isDependentType () && !isCurrentInstantiation))
180186 continue ;
181187
182188 // Determine whether we need to visit this base class at all,
@@ -244,9 +250,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
244250 return FoundPath;
245251 }
246252 } else if (VisitBase) {
247- CXXRecordDecl *BaseRecord;
253+ CXXRecordDecl *BaseRecord = nullptr ;
248254 if (LookupInDependent) {
249- BaseRecord = nullptr ;
250255 const TemplateSpecializationType *TST =
251256 BaseSpec.getType ()->getAs <TemplateSpecializationType>();
252257 if (!TST) {
@@ -265,8 +270,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
265270 BaseRecord = nullptr ;
266271 }
267272 } else {
268- BaseRecord = cast<CXXRecordDecl>(
269- BaseSpec.getType ()->castAs <RecordType>()->getDecl ());
273+ BaseRecord = cast<CXXRecordDecl>(BaseSpec.getType ()->getAsRecordDecl ());
270274 }
271275 if (BaseRecord &&
272276 lookupInBases (Context, BaseRecord, BaseMatches, LookupInDependent)) {
0 commit comments