The fix for PR 97172 that removes non-constant VLA bounds from
attribute access is incomplete: it inadvertently removes the bounds
corresponding to just the first VLA argument, and not from subsequent
arguments.
The attached change removes the vestigial condition that causes this
bug. Since it's behind a build failure in a Fedora package (cava?)
I'll commit it under the "obvious" clause tomorrow if there are no
concerns.
Martin
PR c/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams
gcc/ChangeLog:
* attribs.c (init_attr_rdwr_indices): Guard vblist use.
(attr_access::free_lang_data): Remove a spurious test.
gcc/testsuite/ChangeLog:
* gcc.dg/pr97172.c: Add test cases.
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 81322d40f1d..60933d20810 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -2124,7 +2124,7 @@ init_attr_rdwr_indices (rdwr_map *rwm, tree attrs)
if (*m == '$')
{
++m;
- if (!acc.size)
+ if (!acc.size && vblist)
{
/* Extract the list of VLA bounds for the current
parameter, store it in ACC.SIZE, and advance
@@ -2252,10 +2252,6 @@ attr_access::free_lang_data (tree attrs)
if (!vblist)
continue;
- vblist = TREE_VALUE (vblist);
- if (!vblist)
- continue;
-
for (vblist = TREE_VALUE (vblist); vblist; vblist = TREE_CHAIN (vblist))
{
tree *pvbnd = &TREE_VALUE (vblist);
diff --git a/gcc/testsuite/gcc.dg/pr97172.c b/gcc/testsuite/gcc.dg/pr97172.c
index ab5b2e9e7e9..8ae6342db7f 100644
--- a/gcc/testsuite/gcc.dg/pr97172.c
+++ b/gcc/testsuite/gcc.dg/pr97172.c
@@ -30,21 +30,52 @@ void fnp1_np1_np1 (int a[n + 1][n + 1][n + 1]);
void gn (int a[n]) { fn (a); }
void gnp1 (int a[n + 1]) { fnp1 (a); }
+void gnd2p1 (int a[n / 2 + 1]) { fnp1 (a); }
void gx_n (int a[][n]) { fx_n (a); }
void gx_np1 (int a[][n + 1]) { fx_np1 (a); }
+void gx_nd2p1 (int a[][n / 2 + 1]) { fx_np1 (a); }
void g2_n (int a[2][n]) { f2_n (a); }
void g2_np1 (int a[2][n + 1]) { f2_np1 (a); }
+void g2_nd2p1 (int a[2][n / 2 + 1]) { f2_np1 (a); }
void gn_3 (int a[n][3]) { fn_3 (a); }
void gnp1_3 (int a[n + 1][3]) { fnp1_3 (a); }
+void gnd2p1_3 (int a[n / 2 + 1][3]) { fnp1_3 (a); }
void gn_n (int a[n][n]) { fn_n (a); }
void gn_np1 (int a[n][n + 1]) { fn_np1 (a); }
void gnp1_np1 (int a[n + 1][n + 1]) { fnp1_np1 (a); }
+void gnd2p1_nd2p1 (int a[n / 2 + 1][n / 2 + 1]) { fnp1_np1 (a); }
void gn_n_n (int a[n][n][n]) { fn_n_n (a); }
void gn_n_np1 (int a[n][n][n + 1]) { fn_n_np1 (a); }
void gn_np1_np1 (int a[n][n + 1][n + 1]) { fn_np1_np1 (a); }
void gnp1_np1_np1 (int a[n + 1][n + 1][n + 1]) { fnp1_np1_np1 (a); }
+void gnd2p1_nd2p1_nd2p1 (int a[n / 2 + 1][n / 2 + 1][n / 2 + 1])
+{ fnp1_np1_np1 (a); }
+
+
+void fna3_1 (int n,
+ int a[n / 2 + 1],
+ int b[n / 2 + 1],
+ int c[n / 2 + 1]);
+
+void gna3_1 (int n,
+ int a[n / 2 + 1],
+ int b[n / 2 + 1],
+ int c[n / 2 + 1]) { fna3_1 (n, a, b, c); }
+
+void fna3_2_3_4 (int n,
+ int a[n / 2 + 1][n / 2 + 2],
+ int b[n / 2 + 1][n / 2 + 2][n / 2 + 3],
+ int c[n / 2 + 1][n / 2 + 2][n / 2 + 3][n / 2 + 4]);
+
+void gna3_2_3_4 (int n,
+ int a[n / 2 + 1][n / 2 + 2],
+ int b[n / 2 + 1][n / 2 + 2][n / 2 + 3],
+ int c[n / 2 + 1][n / 2 + 2][n / 2 + 3][n / 2 + 4])
+{
+ fna3_2_3_4 (n, a, b, c);
+}