[clang] [clang] Fix overload resolution ranking of inherited constructors (PR #132830)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 09:25:30 PDT 2025
================
@@ -169,6 +169,20 @@ B b;
// since-cxx11-error at -1 {{call to implicitly-deleted default constructor of 'B'}}
// since-cxx11-note@#cwg2273-B {{default constructor of 'B' is implicitly deleted because base class 'A' has a deleted default constructor}}
// since-cxx11-note@#cwg2273-A {{'A' has been explicitly marked deleted here}}
+
+struct X {
+ X(float); // since-cxx11-note {{candidate inherited constructor}}
+ X(void*, int = 0) = delete;
+};
+
+struct Y : X {
+ using X::X; // since-cxx11-note {{constructor from base class 'X' inherited here}}
+ Y(double); // since-cxx11-note {{candidate constructor}}
+ Y(void* const, long = 1);
+};
+
+Y y = 1; // since-cxx11-error {{conversion from 'int' to 'Y' is ambiguous}}
+Y z = nullptr;
----------------
offsetof wrote:
Since the `const` here is at the top level, it is ignored when forming the function type.
The `FIXME` in the test for CWG2277 is not correct: the relevant tiebreaker applies only to constructors. Removed it and marked both 2273 and 2277 as "Clang 21".
https://github.com/llvm/llvm-project/pull/132830
More information about the cfe-commits
mailing list