]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/31331 ([avr] ICE on function attribute syntax for main())
authorAnatoly Sokolov <aesok@post.ru>
Sat, 7 Jul 2007 19:39:36 +0000 (23:39 +0400)
committerAnatoly Sokolov <aesok@gcc.gnu.org>
Sat, 7 Jul 2007 19:39:36 +0000 (23:39 +0400)
PR target/31331
* config/avr/avr.c (avr_naked_function_p): Handle receiving a type
rather than a decl.
(avr_attribute_table): Make "naked" attribute apply to function types
rather than to decls.
(avr_handle_fntype_attribute): New function.

From-SVN: r126447

gcc/ChangeLog
gcc/config/avr/avr.c

index 4475753bb8d2ec8fea520c824d013fbb7f29ab1e..bbdac56ab70a0431451fc14fe0b339a302f980a2 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-07 Anatoly Sokolov <aesok@post.ru>
+
+       PR target/31331
+       * config/avr/avr.c (avr_naked_function_p): Handle receiving a type
+       rather than a decl. 
+       (avr_attribute_table): Make "naked" attribute apply to function types
+       rather than to decls.
+       (avr_handle_fntype_attribute): New function.
+
 2007-07-07  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/32660
index 054831b146174023fc1c85cc22a0f844da0d0566..6833f3558c08f661f6fcc39300f98e8819f6f34f 100644 (file)
@@ -62,6 +62,7 @@ static RTX_CODE compare_condition (rtx insn);
 static int compare_sign_p (rtx insn);
 static tree avr_handle_progmem_attribute (tree *, tree, tree, int, bool *);
 static tree avr_handle_fndecl_attribute (tree *, tree, tree, int, bool *);
+static tree avr_handle_fntype_attribute (tree *, tree, tree, int, bool *);
 const struct attribute_spec avr_attribute_table[];
 static bool avr_assemble_integer (rtx, unsigned int, int);
 static void avr_file_start (void);
@@ -361,7 +362,7 @@ avr_naked_function_p (tree func)
 
   gcc_assert (TREE_CODE (func) == FUNCTION_DECL);
   
-  a = lookup_attribute ("naked", DECL_ATTRIBUTES (func));
+  a = lookup_attribute ("naked", TYPE_ATTRIBUTES (TREE_TYPE (func)));
   return a != NULL_TREE;
 }
 
@@ -4617,7 +4618,7 @@ const struct attribute_spec avr_attribute_table[] =
   { "progmem",   0, 0, false, false, false,  avr_handle_progmem_attribute },
   { "signal",    0, 0, true,  false, false,  avr_handle_fndecl_attribute },
   { "interrupt", 0, 0, true,  false, false,  avr_handle_fndecl_attribute },
-  { "naked",     0, 0, true,  false, false,  avr_handle_fndecl_attribute },
+  { "naked",     0, 0, false, true,  true,   avr_handle_fntype_attribute },
   { NULL,        0, 0, false, false, false, NULL }
 };
 
@@ -4709,6 +4710,22 @@ avr_handle_fndecl_attribute (tree *node, tree name,
   return NULL_TREE;
 }
 
+static tree
+avr_handle_fntype_attribute (tree *node, tree name,
+                             tree args ATTRIBUTE_UNUSED,
+                             int flags ATTRIBUTE_UNUSED,
+                             bool *no_add_attrs)
+{
+  if (TREE_CODE (*node) != FUNCTION_TYPE)
+    {
+      warning (OPT_Wattributes, "%qs attribute only applies to functions",
+              IDENTIFIER_POINTER (name));
+      *no_add_attrs = true;
+    }
+
+  return NULL_TREE;
+}
+
 /* Look for attribute `progmem' in DECL
    if found return 1, otherwise 0.  */