]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/80462 ([avr] Incorrect "warning: uninitialized variable 'xxx...
authorGeorg-Johann Lay <avr@gjlay.de>
Tue, 22 Aug 2017 09:29:30 +0000 (09:29 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Tue, 22 Aug 2017 09:29:30 +0000 (09:29 +0000)
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

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

index 38eff4bf6e1ab737f3ae7651005ae22b07f7f6e6..7928130304b19ef7cd8883be949e34dc4a29153c 100644 (file)
@@ -1,3 +1,28 @@
+2017-08-22  Georg-Johann Lay  <avr@gjlay.de>
+
+       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  <avr@gjlay.de>
 
        Backport from 2017-08-22 trunk r251256.
index 160846e0901770dc260e2ce6f07c1d8f942a8eff..497478c7a9f29a36db72f7e80e2cfc63c72e4a55 100644 (file)
 #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);