/* Create the attribute access string from the arg spec string,
optionally followed by position of the VLA bound argument if
it is one. */
- char specbuf[80];
- int len = snprintf (specbuf, sizeof specbuf, "%c%u%s",
- attr_access::mode_chars[access_deferred],
- argpos, s);
- gcc_assert ((size_t) len < sizeof specbuf);
-
- if (!spec.length ())
- spec += '+';
+ {
+ size_t specend = spec.length ();
+ if (!specend)
+ {
+ spec = '+';
+ specend = 1;
+ }
- spec += specbuf;
+ /* Format the access string in place. */
+ int len = snprintf (NULL, 0, "%c%u%s",
+ attr_access::mode_chars[access_deferred],
+ argpos, s);
+ spec.resize (specend + len + 1);
+ sprintf (&spec[specend], "%c%u%s",
+ attr_access::mode_chars[access_deferred],
+ argpos, s);
+ /* Trim the trailing NUL. */
+ spec.resize (specend + len);
+ }
/* The (optional) list of expressions denoting the VLA bounds
N in ARGTYPE <arg>[Ni]...[Nj]...[Nk]. */
{
/* BOUND previously seen in the parameter list. */
TREE_PURPOSE (vb) = size_int (*psizpos);
- sprintf (specbuf, "$%u", *psizpos);
- spec += specbuf;
+ /* Format the position string in place. */
+ int len = snprintf (NULL, 0, "$%u", *psizpos);
+ size_t specend = spec.length ();
+ spec.resize (specend + len + 1);
+ sprintf (&spec[specend], "$%u", *psizpos);
+ /* Trim the trailing NUL. */
+ spec.resize (specend + len);
}
else
{
--- /dev/null
+/* PR c/100619 - ICE on a VLA parameter with too many dimensions
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+extern int n;
+
+#define A10 [n][n][n][n][n][n][n][n][n][n]
+#define A100 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10
+#define A1000 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100
+
+void f10 (int A10);
+void f10 (int A10);
+
+void f100 (int A100);
+void f100 (int A100);
+
+void f1000 (int A1000);
+void f1000 (int A1000);
+
+void fx_1000 (int [ ]A1000);
+void fx_1000 (int [1]A1000); // { dg-warning "-Warray-parameter" }
+
+void fn_1000 (int [n ]A1000);
+void fn_1000 (int [n + 1]A1000); // { dg-warning "-Wvla-parameter" }