diff mbox

[avr] Fir PR91910: ICE for bad attribute "address".

Message ID 369a3ac9-88d6-cb43-0d8a-43d66f67c8b3@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Aug. 21, 2017, 12:35 p.m. UTC
"address" attribute only must be specified with VARs,
yet the compiler dived into attribute analysis for
non-VARs, resulting in ICE.

This patch also adds OPT_Wattributes as warning filter.

Ok to apply?

Johann

gcc/
	PR target/81910
	* config/avr/avr.c (avr_handle_addr_attribute): Early return if
	not VAR_P. Filter attribute warnings with OPT_Wattributes.
	(avr_attribute_table) <io, io_low, address>: Initialize
	.decl_required with true.

Comments

Denis Chertykov Aug. 21, 2017, 7:11 p.m. UTC | #1
2017-08-21 16:35 GMT+04:00 Georg-Johann Lay <avr@gjlay.de>:
> "address" attribute only must be specified with VARs,
> yet the compiler dived into attribute analysis for
> non-VARs, resulting in ICE.
>
> This patch also adds OPT_Wattributes as warning filter.
>
> Ok to apply?

Approved.
Please apply.


>
> Johann
>
> gcc/
>         PR target/81910
>         * config/avr/avr.c (avr_handle_addr_attribute): Early return if
>         not VAR_P. Filter attribute warnings with OPT_Wattributes.
>         (avr_attribute_table) <io, io_low, address>: Initialize
>         .decl_required with true.
diff mbox

Patch

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 251142)
+++ config/avr/avr.c	(working copy)
@@ -9790,10 +9790,12 @@  avr_handle_addr_attribute (tree *node, t
   bool io_p = (strncmp (IDENTIFIER_POINTER (name), "io", 2) == 0);
   location_t loc = DECL_SOURCE_LOCATION (*node);
 
-  if (TREE_CODE (*node) != VAR_DECL)
+  if (!VAR_P (*node))
     {
-      warning_at (loc, 0, "%qE attribute only applies to variables", name);
+      warning_at (loc, OPT_Wattributes, "%qE attribute only applies to "
+		  "variables", name);
       *no_add = true;
+      return NULL_TREE;
     }
 
   if (args != NULL_TREE)
@@ -9803,8 +9805,8 @@  avr_handle_addr_attribute (tree *node, t
       tree arg = TREE_VALUE (args);
       if (TREE_CODE (arg) != INTEGER_CST)
 	{
-	  warning (0, "%qE attribute allows only an integer constant argument",
-		   name);
+	  warning_at (loc, OPT_Wattributes, "%qE attribute allows only an "
+		      "integer constant argument", name);
 	  *no_add = true;
 	}
       else if (io_p
@@ -9813,19 +9815,20 @@  avr_handle_addr_attribute (tree *node, t
 			? low_io_address_operand : io_address_operand)
 			 (GEN_INT (TREE_INT_CST_LOW (arg)), QImode)))
 	{
-	  warning_at (loc, 0, "%qE attribute address out of range", name);
+	  warning_at (loc, OPT_Wattributes, "%qE attribute address "
+		      "out of range", name);
 	  *no_add = true;
 	}
       else
 	{
 	  tree attribs = DECL_ATTRIBUTES (*node);
-	  const char *names[] = { "io", "io_low", "address", NULL } ;
+	  const char *names[] = { "io", "io_low", "address", NULL };
 	  for (const char **p = names; *p; p++)
 	    {
 	      tree other = lookup_attribute (*p, attribs);
 	      if (other && TREE_VALUE (other))
 		{
-		  warning_at (loc, 0,
+		  warning_at (loc, OPT_Wattributes,
 			      "both %s and %qE attribute provide address",
 			      *p, name);
 		  *no_add = true;
@@ -9836,7 +9839,8 @@  avr_handle_addr_attribute (tree *node, t
     }
 
   if (*no_add == false && io_p && !TREE_THIS_VOLATILE (*node))
-    warning_at (loc, 0, "%qE attribute on non-volatile variable", name);
+    warning_at (loc, OPT_Wattributes, "%qE attribute on non-volatile variable",
+		name);
 
   return NULL_TREE;
 }
@@ -9886,11 +9890,11 @@  avr_attribute_table[] =
     false },
   { "OS_main",   0, 0, false, true,  true,   avr_handle_fntype_attribute,
     false },
-  { "io",        0, 1, false, false, false,  avr_handle_addr_attribute,
+  { "io",        0, 1, true, false, false,  avr_handle_addr_attribute,
     false },
-  { "io_low",    0, 1, false, false, false,  avr_handle_addr_attribute,
+  { "io_low",    0, 1, true, false, false,  avr_handle_addr_attribute,
     false },
-  { "address",   1, 1, false, false, false,  avr_handle_addr_attribute,
+  { "address",   1, 1, true, false, false,  avr_handle_addr_attribute,
     false },
   { "absdata",   0, 0, true, false, false,  avr_handle_absdata_attribute,
     false },