diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2017-07-12 13:58:34 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2017-07-12 13:58:34 +0000 |
commit | 8b718de8a7c45667773cd684b4e8267cfa8a27a7 (patch) | |
tree | 9bb1053b374d65ac261d775edf1f9021244ba4b9 | |
parent | 6ea93a64ff1e9204d0366e359876a30682ff7c0c (diff) | |
download | gcc-8b718de8a7c45667773cd684b4e8267cfa8a27a7.zip gcc-8b718de8a7c45667773cd684b4e8267cfa8a27a7.tar.gz gcc-8b718de8a7c45667773cd684b4e8267cfa8a27a7.tar.bz2 |
re PR target/81407 ([avr] Diagnose if a variable in progmem needs constructing.)
PR target/81407
* config/avr/avr.c (avr_encode_section_info)
[progmem && !TREE_READONLY]: Error if progmem object needs
constructing.
From-SVN: r250151
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/avr/avr.c | 24 |
2 files changed, 23 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e3d096c..46ca90b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-07-12 Georg-Johann Lay <avr@gjlay.de> + + PR target/81407 + * config/avr/avr.c (avr_encode_section_info) + [progmem && !TREE_READONLY]: Error if progmem object needs + constructing. + 2017-07-11 Michael Collison <michael.collison@arm.com> * config/aarch64/aarch64-simd.md (aarch64_sub<mode>_compare0): diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index d32cac6..a8978ec 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -10376,18 +10376,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))) { - // 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); + } } default_encode_section_info (decl, rtl, new_decl_p); |