From: Georg-Johann Lay Date: Tue, 22 Aug 2017 09:29:30 +0000 (+0000) Subject: backport: re PR target/80462 ([avr] Incorrect "warning: uninitialized variable 'xxx... X-Git-Tag: releases/gcc-5.5.0~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d41b2f566b74cd6d5ebf0f045843a8142fb30e5;p=thirdparty%2Fgcc.git backport: re PR target/80462 ([avr] Incorrect "warning: uninitialized variable 'xxx' put into program memory area" for identical strings) gcc/ Backport from 2017-04-19 trunk r246997. PR target/80462 * config/avr/avr.c (tree.h): Include it. (hash-table.h): Include it. (hash-set.h): Include it. (symtab.h): Include it. (inchash.h): Include it. (function.h): Include it. (hash-map.h): Include it. (plugin-api.h): Include it. (ipa-ref.h): Include it. (cgraph.h): Include it. (avr_encode_section_info): Don't warn for uninitialized progmem variable if it's just an alias. Backport from 2017-07-12 trunk r250151. PR target/81407 * config/avr/avr.c (avr_encode_section_info) [progmem && !TREE_READONLY]: Error if progmem object needs constructing. From-SVN: r251267 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38eff4bf6e1a..7928130304b1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2017-08-22 Georg-Johann Lay + + Backport from 2017-04-19 trunk r246997. + + PR target/80462 + * config/avr/avr.c (tree.h): Include it. + (hash-table.h): Include it. + (hash-set.h): Include it. + (symtab.h): Include it. + (inchash.h): Include it. + (function.h): Include it. + (hash-map.h): Include it. + (plugin-api.h): Include it. + (ipa-ref.h): Include it. + (cgraph.h): Include it. + (avr_encode_section_info): Don't warn for uninitialized progmem + variable if it's just an alias. + + Backport from 2017-07-12 trunk r250151. + + PR target/81407 + * config/avr/avr.c (avr_encode_section_info) + [progmem && !TREE_READONLY]: Error if progmem object needs + constructing. + 2017-08-22 Georg-Johann Lay Backport from 2017-08-22 trunk r251256. diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 160846e09017..497478c7a9f2 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -21,9 +21,19 @@ #include "config.h" #include "system.h" #include "coretypes.h" +#include "hash-table.h" #include "tm.h" #include "hard-reg-set.h" #include "rtl.h" +#include "hash-set.h" +#include "symtab.h" +#include "inchash.h" +#include "tree.h" +#include "function.h" +#include "hash-map.h" +#include "plugin-api.h" +#include "ipa-ref.h" +#include "cgraph.h" #include "regs.h" #include "insn-config.h" #include "conditions.h" @@ -9676,13 +9686,26 @@ avr_encode_section_info (tree decl, rtx rtl, int new_decl_p) if (new_decl_p && decl && DECL_P (decl) - && NULL_TREE == DECL_INITIAL (decl) && !DECL_EXTERNAL (decl) && avr_progmem_p (decl, DECL_ATTRIBUTES (decl))) { - warning (OPT_Wuninitialized, - "uninitialized variable %q+D put into " - "program memory area", decl); + if (!TREE_READONLY (decl)) + { + // This might happen with C++ if stuff needs constructing. + error ("variable %q+D with dynamic initialization put " + "into program memory area", decl); + } + else if (NULL_TREE == DECL_INITIAL (decl)) + { + // Don't warn for (implicit) aliases like in PR80462. + tree asmname = DECL_ASSEMBLER_NAME (decl); + varpool_node *node = varpool_node::get_for_asmname (asmname); + bool alias_p = node && node->alias; + + if (!alias_p) + warning (OPT_Wuninitialized, "uninitialized variable %q+D put " + "into program memory area", decl); + } } default_encode_section_info (decl, rtl, new_decl_p);