================
@@ -4819,33 +4820,35 @@ Sema::BuildBaseInitializer(QualType BaseType,
TypeSourceInfo *BaseTInfo,
return true;
}
+ if (!Dependent &&
+ declaresSameEntity(ClassDecl, BaseType->getAsCXXRecordDecl()))
+ return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
+
// Check for direct and virtual base classes.
const CXXBaseSpecifier *DirectBaseSpec = nullptr;
const CXXBaseSpecifier *VirtualBaseSpec = nullptr;
- if (!Dependent) {
- if (declaresSameEntity(ClassDecl, BaseType->getAsCXXRecordDecl()))
- return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
-
- FindBaseInitializer(*this, ClassDecl, BaseType, DirectBaseSpec,
- VirtualBaseSpec);
-
- // C++ [base.class.init]p2:
- // Unless the mem-initializer-id names a nonstatic data member of the
- // constructor's class or a direct or virtual base of that class, the
- // mem-initializer is ill-formed.
- if (!DirectBaseSpec && !VirtualBaseSpec) {
- // If the class has any dependent bases, then it's possible that
- // one of those types will resolve to the same type as
- // BaseType. Therefore, just treat this as a dependent base
- // class initialization. FIXME: Should we try to check the
- // initialization anyway? It seems odd.
- if (ClassDecl->hasAnyDependentBases())
- Dependent = true;
- else
- return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
- << BaseType << Context.getCanonicalTagType(ClassDecl)
- << BaseTInfo->getTypeLoc().getSourceRange();
- }
+
+ FindBaseInitializer(*this, ClassDecl, BaseType, DirectBaseSpec,
+ VirtualBaseSpec);
+
+ // C++ [base.class.init]p2:
+ // Unless the mem-initializer-id names a nonstatic data member of the
+ // constructor's class or a direct or virtual base of that class, the
+ // mem-initializer is ill-formed.
+ if (!DirectBaseSpec && !VirtualBaseSpec) {
+ // If the class has any dependent bases, then it's possible that one of
+ // those types will resolve to the same type as BaseType. Therefore, just
+ // treat this as a dependent base class initialization.
+ // FIXME: Should we try to check the initialization anyway? It seems odd.
+ if (ClassDecl->hasAnyDependentBases())
+ Dependent = true;
+ // We may have a delegating initializer here but in a dependent context.
+ // Since that is also a type, that isn't a direct or virtual base of the
+ // instantiated type. That will be handled later.
+ else if (!declaresSameEntity(ClassDecl, BaseType->getAsCXXRecordDecl()))
+ return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
+ << BaseType << Context.getCanonicalTagType(ClassDecl)
+ << BaseTInfo->getTypeLoc().getSourceRange();
----------------
spaits wrote:
I have made some indentation changes temporarily for better reviewer
experience. However later on I will have to adjust the indentation to the
changes in the condition guarding (the removing of the condition) this code.
https://github.com/llvm/llvm-project/pull/201379
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits