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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |msebor at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org
            Summary|[9 Regression] ICE: tree    |[9 Regression] ICE on
                   |check: expected class       |attribute copy with a
                   |'type', have 'expression'   |compound expression
                   |(compound_expr) in          |
                   |diag_attr_exclusions, at    |
                   |attribs.c:396               |

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The code in handle_copy_attribute assume that NODE is either a DECL or a TYPE. 
In this case it's a COMPOUND_EXPR:

  /* NODE is either the current DECL to which the attribute is being
     applied or its TYPE.  For the former, consider the attributes on
     both the DECL and its type.  */
  tree attrs[2];

  if (DECL_P (node))
    {
      attrs[0] = DECL_ATTRIBUTES (node);
      attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node));
    }
  else
    {
      attrs[0] = TYPE_ATTRIBUTES (node);   <<< ICE here
      attrs[1] = NULL_TREE;
    }

This otherwise untested change avoids the ICE but there may be a better way to
fix it.

index adf497322da..aaf8d10dc23 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -393,7 +393,10 @@ diag_attr_exclusions (tree last_decl, tree node, tree
attrname,
     }
   else
     {
-      attrs[0] = TYPE_ATTRIBUTES (node);
+      if (TYPE_P (node))
+       attrs[0] = TYPE_ATTRIBUTES (node);
+      else
+       attrs[0] = TYPE_ATTRIBUTES (TREE_TYPE (node));
       attrs[1] = NULL_TREE;
     }

Reply via email to