diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-09-20 12:31:40 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-09-20 12:31:40 -0400 |
commit | 06557ba12b64c57368673c46a21b14cf4e6afb50 (patch) | |
tree | 356dd355ed589f5e9cc3c13fe75c0146798df41a /gcc/cp | |
parent | 33cb400b2e7266e65030869254366217e51494aa (diff) | |
download | gcc-06557ba12b64c57368673c46a21b14cf4e6afb50.zip gcc-06557ba12b64c57368673c46a21b14cf4e6afb50.tar.gz gcc-06557ba12b64c57368673c46a21b14cf4e6afb50.tar.bz2 |
c++: CWG 2273 and non-constructors
Our implementation of the CWG 2273 inheritedness tiebreaker seems to be
incorrectly considering all member functions introduced via using, not
just constructors. This patch restricts the tiebreaker accordingly.
DR 2273
gcc/cp/ChangeLog:
* call.cc (joust): Restrict inheritedness tiebreaker to
constructors.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/using1.C: Expect ambiguity for non-constructor call.
* g++.dg/overload/using5.C: Likewise.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/call.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 3f753e2..6229dc4 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13350,13 +13350,10 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn, } } - /* F1 is a member of a class D, F2 is a member of a base class B of D, and - for all arguments the corresponding parameters of F1 and F2 have the same - type (CWG 2273/2277). */ - if (DECL_P (cand1->fn) && DECL_CLASS_SCOPE_P (cand1->fn) - && !DECL_CONV_FN_P (cand1->fn) - && DECL_P (cand2->fn) && DECL_CLASS_SCOPE_P (cand2->fn) - && !DECL_CONV_FN_P (cand2->fn)) + /* F1 is a constructor for a class D, F2 is a constructor for a base class B + of D, and for all arguments the corresponding parameters of F1 and F2 have + the same type (CWG 2273/2277). */ + if (DECL_INHERITED_CTOR (cand1->fn) || DECL_INHERITED_CTOR (cand2->fn)) { tree base1 = DECL_CONTEXT (strip_inheriting_ctors (cand1->fn)); tree base2 = DECL_CONTEXT (strip_inheriting_ctors (cand2->fn)); |