The syntactically valid but undefined test case submitted in bug 85956 shows that the pretty-printer ICEs when passed a pointer to variable-length array whose upper bound is an error-mark-node.
The ICE is triggered by -Warray-bounds discovering that a negative subscript into the VLA is out-of-bounds and trying to mention the type of the VLA in the diagnostic. The error bound appears to be the result of the omp pass. The attached change avoids the ICE by ignoring error-mark-node as an array bound. It results in -Warray-bounds printing: array subscript -1 is below array bounds of ‘int[]’ for the VLA type. That's not ideal because the printed type is indistinguishable from an array with an unknown bound, but in the absence of a valid bound I can't really think of a solution that's much better (but see below). Without -fopenmp, when it detects an invalid index into a VLA -Warray-bounds might print something like: array subscript -1 is below array bounds of ‘int[<Uef30> + 1]’ The <Uef30> + 1 represents the variable-length upper bound. That doesn't seem particularly informative or helpful but since it's unrelated to the ICE (and might come up in other diagnostics besides -Warray-bounds) I haven't changed it in the attached patch. If we want to print VLAs differently in diagnostics I think it should be done in a separate change. One possibility is to leave the bound out altogether as this patch does. Another is to use the C [*] VLA syntax. That should turn the above into: array subscript -1 is below array bounds of ‘int[*]’ This notation could be used just for valid VLAs or also for the openmp VLAs with an error upper bound if they can't be made valid. Martin
PR middle-end/85956 - ICE in wide_int_to_tree_1:1549 gcc/c-family/ChangeLog: PR middle-end/85956 * c-pretty-print.c (c_pretty_printer::direct_abstract_declarator): Handle error-mark-node in array bounds gracefully. gcc/testsuite/ChangeLog: PR middle-end/85956 * gcc.dg/gomp/pr85956.c: New test. Index: gcc/c-family/c-pretty-print.c =================================================================== --- gcc/c-family/c-pretty-print.c (revision 260969) +++ gcc/c-family/c-pretty-print.c (working copy) @@ -570,20 +570,26 @@ c_pretty_printer::direct_abstract_declarator (tree break; case ARRAY_TYPE: - pp_c_left_bracket (this); - if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t))) - { - tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t)); - tree type = TREE_TYPE (maxval); + { + pp_c_left_bracket (this); - if (tree_fits_shwi_p (maxval)) - pp_wide_integer (this, tree_to_shwi (maxval) + 1); - else - expression (fold_build2 (PLUS_EXPR, type, maxval, - build_int_cst (type, 1))); - } - pp_c_right_bracket (this); - direct_abstract_declarator (TREE_TYPE (t)); + if (tree dom = TYPE_DOMAIN (t)) + { + tree maxval = TYPE_MAX_VALUE (dom); + if (maxval && maxval != error_mark_node) + { + tree type = TREE_TYPE (maxval); + + if (tree_fits_shwi_p (maxval)) + pp_wide_integer (this, tree_to_shwi (maxval) + 1); + else + expression (fold_build2 (PLUS_EXPR, type, maxval, + build_int_cst (type, 1))); + } + } + pp_c_right_bracket (this); + direct_abstract_declarator (TREE_TYPE (t)); + } break; case IDENTIFIER_NODE: Index: gcc/testsuite/gcc.dg/gomp/pr85956.c =================================================================== --- gcc/testsuite/gcc.dg/gomp/pr85956.c (nonexistent) +++ gcc/testsuite/gcc.dg/gomp/pr85956.c (working copy) @@ -0,0 +1,13 @@ +/* PR middle-end/85956 - ICE in wide_int_to_tree_1, at tree.c:1549 + { dg-do compile } + { dg-options "-O2 -Wall -fopenmp" } */ + +void foo (int n, void *p) +{ + int (*a)[n] = (int (*)[n]) p; + +#pragma omp parallel shared(a) default(none) +#pragma omp master + + a[-1][-1] = 42; /* { dg-warning "\\\[-Warray-bounds]" } */ +}