re PR target/80462 ([avr] Incorrect "warning: uninitialized variable 'xxx' put into...
authorGeorg-Johann Lay <avr@gjlay.de>
Wed, 19 Apr 2017 12:20:57 +0000 (12:20 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Wed, 19 Apr 2017 12:20:57 +0000 (12:20 +0000)
PR target/80462
* config/avr/avr.c (tree.h): Include it.
(cgraph.h): Include it.
(avr_encode_section_info): Don't warn for uninitialized progmem
variable if it's just an alias.

From-SVN: r246997

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

index 85025d4a402c31d7c6998db81a5d1087ea8a3648..1995cd536b0a643165f5a68bad8552957263c3dd 100644 (file)
@@ -1,3 +1,11 @@
+2017-04-19  Georg-Johann Lay  <avr@gjlay.de>
+
+       PR target/80462
+       * config/avr/avr.c (tree.h): Include it.
+       (cgraph.h): Include it.
+       (avr_encode_section_info): Don't warn for uninitialized progmem
+       variable if it's just an alias.
+
 2017-04-19  Richard Biener  <rguenther@suse.de>
 
        PR ipa/65972
index dde712c49c7f149112b742eb3b112ee2fd929301..648a1256f803dfc896ce277a83c6d9dbaaa2a8f5 100644 (file)
@@ -25,6 +25,8 @@
 #include "backend.h"
 #include "target.h"
 #include "rtl.h"
+#include "tree.h"
+#include "cgraph.h"
 #include "c-family/c-common.h"
 #include "cfghooks.h"
 #include "df.h"
@@ -10127,9 +10129,14 @@ avr_encode_section_info (tree decl, rtx rtl, int new_decl_p)
       && !DECL_EXTERNAL (decl)
       && avr_progmem_p (decl, DECL_ATTRIBUTES (decl)))
     {
-      warning (OPT_Wuninitialized,
-               "uninitialized variable %q+D put into "
-               "program memory area", 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);