On 12/2/25 2:30 PM, Jakub Jelinek wrote:
Hi!

The following testcase ICEs since r12-7741 on the newly added gcc_assert.
We've diagnosed the designator is invalid before, but kept it as is.

The following patch changes it into error_mark_node, so that don't ICE on
it.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.
2025-12-02  Jakub Jelinek  <[email protected]>

        PR c++/122836
        * decl.cc (check_array_designated_initializer): Change ce->index to
        error_mark_node after emitting an error for it.

        * g++.dg/ext/pr122836.C: New test.

--- gcc/cp/decl.cc.jj   2025-11-29 17:37:50.458642545 +0100
+++ gcc/cp/decl.cc      2025-12-01 13:23:50.255133865 +0100
@@ -6981,6 +6981,7 @@ check_array_designated_initializer (cons
        {
          error ("name %qD used in a GNU-style designated "
                 "initializer for an array", ce->index);
+         ce->index = error_mark_node;
          return false;
        }
--- gcc/testsuite/g++.dg/ext/pr122836.C.jj 2025-12-01 13:28:08.830646802 +0100
+++ gcc/testsuite/g++.dg/ext/pr122836.C 2025-12-01 13:27:26.940373723 +0100
@@ -0,0 +1,11 @@
+// PR c++/122836
+// { dg-do compile }
+// { dg-options "" }
+
+struct V { __attribute__ ((__vector_size__ (2 * sizeof (float)))) float v[2]; 
};
+
+V
+foo ()
+{
+  return (V) { { .v = { 0, 0 } } };    // { dg-error "name 'v' used in a GNU-style 
designated initializer for an array" }
+}

        Jakub


Reply via email to