PR c++/92552 - ICE with inherited constrained default ctor.
authorJason Merrill <jason@redhat.com>
Tue, 7 Jan 2020 01:07:59 +0000 (20:07 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 7 Jan 2020 01:07:59 +0000 (20:07 -0500)
We set TYPE_HAS_USER_CONSTRUCTOR on the template type in lookup_using_decl,
but we didn't copy it to the instantiation.  Setting it in
one_inherited_ctor is too late, as that gets called after we decide whether
to set CLASSTYPE_LAZY_DEFAULT_CTOR.  This change affects other testcases as
well; the changes are fixes for the other inherited constructor tests as
well.

* pt.c (instantiate_class_template_1): Copy
TYPE_HAS_USER_CONSTRUCTOR.
* class.c (one_inherited_ctor): Don't set it here.

From-SVN: r279936

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/concepts/inherit-ctor3.C
gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor2.C
gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash7.C
gcc/testsuite/g++.old-deja/g++.pt/error2.C

index 02ebb9fbf9421b2c4bbe15c3147d1079b60bb470..abcbba559e32537cb35381fd9579de6dc68ed492 100644 (file)
@@ -1,3 +1,10 @@
+2020-01-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/92552 - ICE with inherited constrained default ctor.
+       * pt.c (instantiate_class_template_1): Copy
+       TYPE_HAS_USER_CONSTRUCTOR.
+       * class.c (one_inherited_ctor): Don't set it here.
+
 2020-01-06  Andrew Sutton  <asutton@lock3software.com>
 
        PR c++/92739 - parsing requires clause with attributes.
index 4da08812702f4344d813025d7d255c5f276c89e5..07abe5298d173a3b58123bde3dce50ae6cf7e911 100644 (file)
@@ -3141,7 +3141,6 @@ one_inherited_ctor (tree ctor, tree t, tree using_decl)
       ctor = implicitly_declare_fn (sfk_inheriting_constructor,
                                    t, /*const*/false, ctor, parms);
       add_method (t, ctor, using_decl != NULL_TREE);
-      TYPE_HAS_USER_CONSTRUCTOR (t) = true;
       return;
     }
 
index bc23e9e03548765453988f06f39db45c600f5b66..cd48f533d5d921fb484a95f264fabda0155bdef8 100644 (file)
@@ -11544,6 +11544,7 @@ 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))
index abfe96e824019ef898f718d5b7f4746196e8cbfa..dda202f4c248db739f9c1e505f1d49a481436d00 100644 (file)
@@ -11,7 +11,7 @@ template<typename T>
   };
 
 template<typename T>
-  struct S2 : S1<T> { // { dg-error "no matching function" }
+  struct S2 : S1<T> {
     using S1<T>::S1; // { dg-error "no matching function" }
   };
 
@@ -19,5 +19,5 @@ struct X { } x;
 
 int main() {
   S2<X> s1(0); // { dg-error "use of deleted function" }
-  S2<X> s2; // { dg-error "use of deleted function" }
+  S2<X> s2; // { dg-error "no matching function" }
 }
index aa244bc04c1222d1aee680910d178563addb2b1f..82d14746df2e1857ef2fbaa4b947e9a125cac2c5 100644 (file)
@@ -9,10 +9,10 @@ template<typename T>
   };
 
 template<typename T>
-  struct S2 : S1<T> { // { dg-error "matching" }
+  struct S2 : S1<T> {
     using S1<T>::S1;
   };
 
 int main() {
-  S2<int> s; // { dg-error "deleted function" }
+  S2<int> s; // { dg-error "no matching function" }
 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor7.C b/gcc/testsuite/g++.dg/cpp2a/concepts-inherit-ctor7.C
new file mode 100644 (file)
index 0000000..2592b52
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/92552
+// { dg-do compile { target concepts } }
+
+template <typename T> struct basic_mixin {
+  basic_mixin() requires true;
+};
+template <typename Cur>
+struct mixin : basic_mixin<Cur> {
+  using basic_mixin<Cur>::basic_mixin;
+};
+int main() {
+  (void)__is_constructible(mixin<int>);
+  // noexcept(mixin<int>()); also triggers ICE
+}
index 691628e787817eab00bc2c9191cd60a5a5d6e080..00d387c1197fce201f8d50b64317b0f60fb2d842 100644 (file)
@@ -10,6 +10,4 @@ template <typename> struct A
     template <typename> A(typename A::X) {} // { dg-error "incomplete" }
 };
 
-// We currently don't give the "no match" error because we don't add the
-// invalid constructor template to TYPE_METHODS.
-A<void> a;                     // { dg-message "required" }
+A<void> a;                     // { dg-message "no match" }
index 2e65718b67957f8f304c26cfc2bc95750944a933..666aea0a1ef43ded29b74a88c2c4260489e6a919 100644 (file)
@@ -9,7 +9,7 @@ public:
 
 void f ()
 {
-  Test<void> c; // { dg-message "required" }
+  Test<void> c; // { dg-error "no match" }
 }