@@ -170,13 +170,21 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
170170 QualType BaseType =
171171 Context.getCanonicalType (BaseSpec.getType ()).getUnqualifiedType ();
172172
173+ bool isCurrentInstantiation = isa<InjectedClassNameType>(BaseType);
174+ if (!isCurrentInstantiation) {
175+ if (auto *BaseRecord = cast_or_null<CXXRecordDecl>(
176+ BaseSpec.getType ()->getAsRecordDecl ()))
177+ isCurrentInstantiation = BaseRecord->isDependentContext () &&
178+ BaseRecord->isCurrentInstantiation (Record);
179+ }
173180 // C++ [temp.dep]p3:
174181 // In the definition of a class template or a member of a class template,
175182 // if a base class of the class template depends on a template-parameter,
176183 // the base class scope is not examined during unqualified name lookup
177184 // either at the point of definition of the class template or member or
178185 // during an instantiation of the class tem- plate or member.
179- if (!LookupInDependent && BaseType->isDependentType ())
186+ if (!LookupInDependent &&
187+ (BaseType->isDependentType () && !isCurrentInstantiation))
180188 continue ;
181189
182190 // Determine whether we need to visit this base class at all,
@@ -244,9 +252,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
244252 return FoundPath;
245253 }
246254 } else if (VisitBase) {
247- CXXRecordDecl *BaseRecord;
255+ CXXRecordDecl *BaseRecord = nullptr ;
248256 if (LookupInDependent) {
249- BaseRecord = nullptr ;
250257 const TemplateSpecializationType *TST =
251258 BaseSpec.getType ()->getAs <TemplateSpecializationType>();
252259 if (!TST) {
@@ -265,8 +272,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
265272 BaseRecord = nullptr ;
266273 }
267274 } else {
268- BaseRecord = cast<CXXRecordDecl>(
269- BaseSpec.getType ()->castAs <RecordType>()->getDecl ());
275+ BaseRecord = cast<CXXRecordDecl>(BaseSpec.getType ()->getAsRecordDecl ());
270276 }
271277 if (BaseRecord &&
272278 lookupInBases (Context, BaseRecord, BaseMatches, LookupInDependent)) {
0 commit comments