]> gcc.gnu.org Git - gcc.git/commitdiff
backport: re PR c++/87506 (ICE with inherited constexpr constructor with const argument)
authorJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:17:41 +0000 (13:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:17:41 +0000 (13:17 +0200)
Backported from mainline
2018-12-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/87506
* constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR.

* g++.dg/cpp0x/constexpr-87506.C: New test.

From-SVN: r275075

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C [new file with mode: 0644]

index 1c416bcb0b68a36330c71ce3846020cde583664f..64bf90ae6347451cadcc053c5abaf07140b6fe68 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
        Backported from mainline
+       2018-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87506
+       * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR.
+
        2018-12-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/88103
index cfd6a3a0e6e19893f950ff54159cab0c9d1adf70..010b75271db65c91aa927b08f6c2ebe9cfccaae3 100644 (file)
@@ -1212,6 +1212,8 @@ adjust_temp_type (tree type, tree temp)
   /* Avoid wrapping an aggregate value in a NOP_EXPR.  */
   if (TREE_CODE (temp) == CONSTRUCTOR)
     return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+  if (TREE_CODE (temp) == EMPTY_CLASS_EXPR)
+    return build0 (EMPTY_CLASS_EXPR, type);
   gcc_assert (scalarish_type_p (type));
   return cp_fold_convert (type, temp);
 }
index 079ea89feffa7f8a0c8fe0388f8e0f4424aca4a0..56aa953bf14034092b4234a41d344abe4d05f6ff 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
        Backported from mainline
+       2018-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87506
+       * g++.dg/cpp0x/constexpr-87506.C: New test.
+
        2018-12-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/88103
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C
new file mode 100644 (file)
index 0000000..62d2ddc
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/87506
+// { dg-do compile { target c++11 } }
+
+struct A {};
+struct B { constexpr B (const A) {} };
+struct C : B { using B::B; };
+
+void
+foo ()
+{
+  C c (A{});
+}
This page took 0.096303 seconds and 5 git commands to generate.