diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-14 13:59:54 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-14 15:20:12 -0500 |
commit | 08c8c973c082457a7d6192673e87475f1fdfdbef (patch) | |
tree | b04556341be3025f2077cdc3fe0e0c9fa9122bcf /gcc/cp | |
parent | a5a3c2dcf73aa245b0eb6f6cf56c4d03ab6056da (diff) | |
download | gcc-08c8c973c082457a7d6192673e87475f1fdfdbef.zip gcc-08c8c973c082457a7d6192673e87475f1fdfdbef.tar.gz gcc-08c8c973c082457a7d6192673e87475f1fdfdbef.tar.bz2 |
PR c++/92590 - wrong handling of inherited default ctor.
I thought my earlier fix for 91930 was an obvious bug fix, but apparently an
inherited constructor does not count as user-declared. So this patch
reverts that change and the other follow-on patches, and fixes 91930
differently, by not letting the inherited default constructor hide the
implicitly-declared default constructor.
* class.c (add_method): A constrained inherited ctor doesn't hide an
implicit derived ctor.
Revert:
PR c++/91930 - ICE with constrained inherited default ctor.
* name-lookup.c (do_class_using_decl): Set TYPE_HAS_USER_CONSTRUCTOR
for inherited constructor.
PR c++/92552 - ICE with inherited constrained default ctor.
* pt.c (instantiate_class_template_1): Copy
TYPE_HAS_USER_CONSTRUCTOR.
PR c++/92594 - ICE with inherited trivial default ctor.
* method.c (trivial_fn_p): Treat an inherited default constructor
like a normal default constructor.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/class.c | 5 | ||||
-rw-r--r-- | gcc/cp/method.c | 7 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 1 | ||||
-rw-r--r-- | gcc/cp/pt.c | 1 |
5 files changed, 18 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3cc7c48..c137539 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -14,6 +14,20 @@ 2020-01-14 Jason Merrill <jason@redhat.com> + PR c++/92590 - wrong handling of inherited default ctor. + * class.c (add_method): A constrained inherited ctor doesn't hide an + implicit derived ctor. + Revert: + PR c++/92552 - ICE with inherited constrained default ctor. + * pt.c (instantiate_class_template_1): Copy + TYPE_HAS_USER_CONSTRUCTOR. + PR c++/91930 - ICE with constrained inherited default ctor. + * name-lookup.c (do_class_using_decl): Set TYPE_HAS_USER_CONSTRUCTOR + for inherited constructor. + PR c++/92594 - ICE with inherited trivial default ctor. + * method.c (trivial_fn_p): Treat an inherited default constructor + like a normal default constructor. + PR c++/92594 - ICE with inherited trivial default ctor. * method.c (trivial_fn_p): Treat an inherited default constructor like a normal default constructor. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 07abe52..719c3ec 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1079,9 +1079,10 @@ add_method (tree type, tree method, bool via_using) { special_function_kind sfk = special_memfn_p (method); - if (sfk == sfk_none) + if (sfk == sfk_none || DECL_INHERITED_CTOR (fn)) /* Non-special member functions coexist if they are not - equivalently constrained. */ + equivalently constrained. A member function is not hidden + by an inherited constructor. */ continue; /* P0848: For special member functions, deleted, unsatisfied, or diff --git a/gcc/cp/method.c b/gcc/cp/method.c index e20a88f..fef19e1 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -458,12 +458,7 @@ trivial_fn_p (tree fn) /* If fn is a clone, get the primary variant. */ if (tree prim = DECL_CLONED_FUNCTION (fn)) fn = prim; - special_function_kind sfk = special_function_p (fn); - /* An inherited default constructor is equivalent to a non-inherited default - constructor, so let it be trivial. */ - if (sfk == sfk_inheriting_constructor && default_ctor_p (fn)) - sfk = sfk_constructor; - return type_has_trivial_fn (DECL_CONTEXT (fn), sfk); + return type_has_trivial_fn (DECL_CONTEXT (fn), special_function_p (fn)); } /* PARM is a PARM_DECL for a function which we want to forward to another diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 3c2c50d..cd7a581 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4634,7 +4634,6 @@ lookup_using_decl (tree scope, name_lookup &lookup) maybe_warn_cpp0x (CPP0X_INHERITING_CTORS); lookup.name = ctor_identifier; CLASSTYPE_NON_AGGREGATE (current) = true; - TYPE_HAS_USER_CONSTRUCTOR (current) = true; } /* Cannot introduce a constructor name. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4fdc74f..7e675ce 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11578,7 +11578,6 @@ instantiate_class_template_1 (tree type) SET_TYPE_ALIGN (type, TYPE_ALIGN (pattern)); TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern); CLASSTYPE_NON_AGGREGATE (type) = CLASSTYPE_NON_AGGREGATE (pattern); - TYPE_HAS_USER_CONSTRUCTOR (type) = TYPE_HAS_USER_CONSTRUCTOR (pattern); if (ANON_AGGR_TYPE_P (pattern)) SET_ANON_AGGR_TYPE_P (type); if (CLASSTYPE_VISIBILITY_SPECIFIED (pattern)) |