[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 1 01:37:23 PDT 2025
================
@@ -8058,6 +8061,46 @@ bool Sema::CheckNonDependentConversions(
}
}
+ // A speculative workaround for self-dependent constraint bugs that manifest
+ // after CWG2369.
+ // FIXME: Add references to the standard once P3606 is adopted.
+ auto MaybeInvolveUserDefinedConversion = [&](QualType ParmType,
+ QualType ArgType) {
+ ParmType = ParmType.getNonReferenceType();
+ ArgType = ArgType.getNonReferenceType();
+ bool PointerConv = ParmType->isPointerType() && ArgType->isPointerType();
+ if (PointerConv) {
+ ParmType = ParmType->getPointeeType();
+ ArgType = ArgType->getPointeeType();
+ }
+
+ if (auto *RT = ParmType->getAs<RecordType>())
+ if (auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl());
+ RD && RD->hasDefinition()) {
+ if (llvm::any_of(LookupConstructors(RD), [](NamedDecl *ND) {
+ auto Info = getConstructorInfo(ND);
+ if (!Info)
+ return false;
+ CXXConstructorDecl *Ctor = Info.Constructor;
+ /// isConvertingConstructor takes copy/move constructors into
+ /// account!
+ return !Ctor->isCopyOrMoveConstructor() &&
+ Ctor->isConvertingConstructor(
+ /*AllowExplicit=*/true);
+ }))
+ return true;
+ }
----------------
cor3ntin wrote:
GCC did the minimum not to break existing code. Because tag_invoke (and somewhat still is) fairly widely used.
In that light, I think it makes sense to just do as they did, or simpler (to the point it's unclear to me if we should even standardize that behavior)
https://github.com/llvm/llvm-project/pull/122423
More information about the cfe-commits
mailing list