https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69796

--- Comment #2 from prathamesh3492 at gcc dot gnu.org ---
Hi,
I believe this happens because of setting TREE_TYPE (decl) to error_mark_node
in c_parser_translation_unit():

FOR_EACH_VEC_ELT (incomplete_record_decls, i, decl)
    if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node)
      {
        error ("storage size of %q+D isn%'t known", decl);
        TREE_TYPE (decl) = error_mark_node;
      }

this fails at useless_type_conversion_p():
inner_type = TYPE_MAIN_VARIANT (inner_type)
because inner_type == error_mark_node

I wonder what should be the right fix ?
Should the loop not set TREE_TYPE (decl) to error_mark_node
or we return true from useless_type_conversion_p if either outer_type or
inner_type is error_mark_node ?
Both approaches prevent the ICE.
I suppose not setting TREE_TYPE (decl) to error_mark_node in
c_parser_translation_unit() would be better,
since this could again show up at a different place in middle-end ?

Thanks,
Prathamesh

Reply via email to