]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/92015 (internal compiler error: in cxx_eval_array_reference,...
authorJakub Jelinek <jakub@redhat.com>
Fri, 8 Nov 2019 18:52:44 +0000 (19:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 8 Nov 2019 18:52:44 +0000 (19:52 +0100)
Backported from mainline
2019-10-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/92015
* constexpr.c (cxx_eval_component_reference, cxx_eval_bit_field_ref):
Use STRIP_ANY_LOCATION_WRAPPER on CONSTRUCTOR elts.

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

From-SVN: r277980

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

index 86007bde317f019f76f7188b411068aa38e0be47..b8a9441ffc829241d0823ca1ccbf99f8dd42945f 100644 (file)
@@ -1,3 +1,12 @@
+2019-11-08  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-10-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92015
+       * constexpr.c (cxx_eval_component_reference, cxx_eval_bit_field_ref):
+       Use STRIP_ANY_LOCATION_WRAPPER on CONSTRUCTOR elts.
+
 2019-10-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/92201
index a229b48d746811c604c47f92b496de2768802f46..806a812304eb36030348bba841389d87a53b7258 100644 (file)
@@ -2703,7 +2703,10 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
          : field == part)
        {
          if (value)
-           return value;
+           {
+             STRIP_ANY_LOCATION_WRAPPER (value);
+             return value;
+           }
          else
            /* We're in the middle of initializing it.  */
            break;
@@ -2793,6 +2796,7 @@ cxx_eval_bit_field_ref (const constexpr_ctx *ctx, tree t,
   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (whole), i, field, value)
     {
       tree bitpos = bit_position (field);
+      STRIP_ANY_LOCATION_WRAPPER (value);
       if (bitpos == start && DECL_SIZE (field) == TREE_OPERAND (t, 1))
        return value;
       if (TREE_CODE (TREE_TYPE (field)) == INTEGER_TYPE
index 087d24de3510a056e2397d43a2d9873ce7f91aaa..89f8907e413e745ed333808e0a071a857aa9690b 100644 (file)
@@ -1,3 +1,11 @@
+2019-11-08  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-10-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92015
+       * g++.dg/cpp0x/constexpr-92015.C: New test.
+
 2019-11-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/compile/20191108-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-92015.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-92015.C
new file mode 100644 (file)
index 0000000..60f288e
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/92015
+// { dg-do compile { target c++11 } }
+
+struct S1 { char c[6] {'h', 'e', 'l', 'l', 'o', 0}; };
+struct S2 { char c[6] = "hello"; };
+static_assert (S1{}.c[0] == 'h', "");
+static_assert (S2{}.c[0] == 'h', "");