On Sat, Jan 13, 2018 at 12:12:02PM +0100, Jakub Jelinek wrote:
> Or we could not add those error_mark_nodes and
>   gcc_assert (seen_error () || cp_parser_error_occurred (parser));

This fixes the testcase:
--- gcc/cp/parser.c.jj  2018-01-11 18:58:48.386391801 +0100
+++ gcc/cp/parser.c     2018-01-13 12:17:20.545347195 +0100
@@ -13403,6 +13403,9 @@ cp_parser_decl_specifier_seq (cp_parser*
                }
            }
 
+         if (attrs == error_mark_node)
+           gcc_assert (seen_error () || cp_parser_error_occurred (parser));
+         else
            decl_specs->attributes
              = chainon (decl_specs->attributes,
                         attrs);
but there are 13 chainon calls like this in parser.c.  Shouldn't we introduce
a helper function for this, perhaps:

void
attr_chainon (cp_parser *parser, tree *attrs, tree attr)
{
  /* Don't add error_mark_node to the chain, it can't be chained.
     Assert this is during error recovery.  */
  if (attr == error_mark_node)
    gcc_assert (seen_error () || cp_parser_error_occurred (parser));
  else
    *attrs = chainon (*attrs, attr);
}

and change all affected spots, like

          attr_chainon (parser, &decl_specs->attributes, attrs);

?

        Jakub

Reply via email to