From: Georg-Johann Lay Date: Tue, 22 Aug 2017 08:40:15 +0000 (+0000) Subject: backport: re PR target/81910 ([avr] ICE with "address" attribute on type) X-Git-Tag: releases/gcc-5.5.0~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e3d6f9ba8ebb733a94fa9b7ece683cbe4ce7906;p=thirdparty%2Fgcc.git backport: re PR target/81910 ([avr] ICE with "address" attribute on type) gcc/ Backport from 2017-08-22 trunk r251256. 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) : Initialize .decl_required with true. From-SVN: r251261 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 66378de1b5c8..38eff4bf6e1a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-08-22 Georg-Johann Lay + + Backport from 2017-08-22 trunk r251256. + + 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) : Initialize + .decl_required with true. + 2017-08-19 Uros Bizjak PR target/81894 diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 4ffb38c571f5..160846e09017 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -9059,10 +9059,12 @@ avr_handle_addr_attribute (tree *node, tree name, tree args, 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) @@ -9072,8 +9074,8 @@ avr_handle_addr_attribute (tree *node, tree name, tree args, 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 @@ -9082,19 +9084,20 @@ avr_handle_addr_attribute (tree *node, tree name, tree args, ? 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; @@ -9105,7 +9108,8 @@ avr_handle_addr_attribute (tree *node, tree name, tree args, } 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; } @@ -9153,11 +9157,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 }, { NULL, 0, 0, false, false, false, NULL, false } };