diff mbox

[avr,v7,committed] Backport PR81407

Message ID e9f15a6f-654f-2513-5cc3-94ffa821a466@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay July 25, 2017, 2:37 p.m. UTC
Backported from trunk as:

https://gcc.gnu.org/r250522

Johann

gcc/
	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.

    default_encode_section_info (decl, rtl, new_decl_p);
diff mbox

Patch

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c    (revision 250505)
+++ config/avr/avr.c    (working copy)
@@ -10140,18 +10140,26 @@  avr_encode_section_info (tree decl, rtx

    if (new_decl_p
        && decl && DECL_P (decl)
-      && NULL_TREE == DECL_INITIAL (decl)
        && !DECL_EXTERNAL (decl)
        && avr_progmem_p (decl, DECL_ATTRIBUTES (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 (!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);
+          if (!alias_p)
+            warning (OPT_Wuninitialized, "uninitialized variable %q+D put "
+                     "into program memory area", decl);
+        }
      }