On Thu, May 31, 2018 at 2:58 AM, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, May 30, 2018 at 02:39:15PM -0600, Martin Sebor wrote: >> 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. > > This isn't sufficient, as it still ICEs with C++: > during GIMPLE pass: vrp > In function ‘_Z3fooiPv._omp_fn.0’: > tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in > build_int_cst, at tree.c:1342 > #pragma omp parallel shared(a) default(none) > ^~~ > 0x15ef6b3 tree_class_check_failed(tree_node const*, tree_code_class, char > const*, int, char const*) > ../../gcc/tree.c:9385 > 0x80fb7c tree_class_check(tree_node*, tree_code_class, char const*, int, char > const*) > ../../gcc/tree.h:3258 > 0x15d017c build_int_cst(tree_node*, poly_int<1u, long>) > ../../gcc/tree.c:1342 > 0xe2b685 round_up_loc(unsigned int, tree_node*, unsigned int) > ../../gcc/fold-const.c:14330 > 0x1233717 finalize_type_size > ../../gcc/stor-layout.c:1908 > 0x1238390 layout_type(tree_node*) > ../../gcc/stor-layout.c:2578 > 0x15e9d8c build_array_type_1 > ../../gcc/tree.c:7869 > 0x15ea022 build_array_type(tree_node*, tree_node*, bool) > ../../gcc/tree.c:7906 > 0xad28b7 build_cplus_array_type(tree_node*, tree_node*) > ../../gcc/cp/tree.c:985 > 0xad46c5 strip_typedefs(tree_node*, bool*) > ../../gcc/cp/tree.c:1459 > 0x9312a8 type_to_string > ../../gcc/cp/error.c:3176 > 0x93425c cp_printer > ../../gcc/cp/error.c:4085 > 0x1f79f1b pp_format(pretty_printer*, text_info*) > ../../gcc/pretty-print.c:1375 > > I came up with the following hack instead (or in addition to), > replace those error_mark_node bounds with NULL (i.e. pretend flexible array > members) if during OpenMP/OpenACC outlining we've decided not to pass around > the bounds artificial decl because nothing really use it. > > Is this a reasonable hack, or shall we go with Martin's patch + similar > change in C++ pretty printer to handle error_mark_node specially and perhaps > also handle NULL specially too as the patch does, or both those FE changes > and this, something else?
We generally try to avoid embedded error_mark_node within other trees. If the array bound is erroneous, can we replace the whole array type with error_mark_node? Jason