@@ -169,14 +169,18 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
169
169
// Find the record of the base class subobjects for this type.
170
170
QualType BaseType =
171
171
Context.getCanonicalType (BaseSpec.getType ()).getUnqualifiedType ();
172
+ bool isCurrentInstantiation = false ;
173
+ if (auto *TST = BaseSpec.getType ()->getAs <TemplateSpecializationType>())
174
+ isCurrentInstantiation = TST->isCurrentInstantiation ();
172
175
173
176
// C++ [temp.dep]p3:
174
177
// In the definition of a class template or a member of a class template,
175
178
// if a base class of the class template depends on a template-parameter,
176
179
// the base class scope is not examined during unqualified name lookup
177
180
// either at the point of definition of the class template or member or
178
181
// during an instantiation of the class tem- plate or member.
179
- if (!LookupInDependent && BaseType->isDependentType ())
182
+ if (!LookupInDependent &&
183
+ (BaseType->isDependentType () && !isCurrentInstantiation))
180
184
continue ;
181
185
182
186
// Determine whether we need to visit this base class at all,
@@ -244,9 +248,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
244
248
return FoundPath;
245
249
}
246
250
} else if (VisitBase) {
247
- CXXRecordDecl *BaseRecord;
251
+ CXXRecordDecl *BaseRecord = nullptr ;
248
252
if (LookupInDependent) {
249
- BaseRecord = nullptr ;
250
253
const TemplateSpecializationType *TST =
251
254
BaseSpec.getType ()->getAs <TemplateSpecializationType>();
252
255
if (!TST) {
@@ -265,8 +268,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
265
268
BaseRecord = nullptr ;
266
269
}
267
270
} 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 ());
270
273
}
271
274
if (BaseRecord &&
272
275
lookupInBases (Context, BaseRecord, BaseMatches, LookupInDependent)) {
0 commit comments