diff options
author | Anatoly Sokolov <aesok@post.ru> | 2007-07-05 01:10:28 +0400 |
---|---|---|
committer | Anatoly Sokolov <aesok@gcc.gnu.org> | 2007-07-05 01:10:28 +0400 |
commit | 44190aed5ed111b27b8d1be4fa5e4d406dafed86 (patch) | |
tree | 84a7339b747c45548496ce72b136d9c3e58f8a03 | |
parent | 73ed196896673dd1e48aa1d3a7f69c514de43adc (diff) | |
download | gcc-44190aed5ed111b27b8d1be4fa5e4d406dafed86.zip gcc-44190aed5ed111b27b8d1be4fa5e4d406dafed86.tar.gz gcc-44190aed5ed111b27b8d1be4fa5e4d406dafed86.tar.bz2 |
re PR target/31331 ([avr] ICE on function attribute syntax for main())
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: r126337
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/config/avr/avr.c | 21 |
2 files changed, 28 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55a0a5a..60fb88f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2007-07-04 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-04 Joseph Myers <joseph@codesourcery.com> * target-def.h (TARGET_INITIALIZER): Remove trailing whitespace diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index d9dec88..86c834b 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -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); @@ -400,7 +401,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; } @@ -4585,7 +4586,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 } }; @@ -4677,6 +4678,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. */ |