This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, AVR]: Hack around PR34734
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Eric B. Weddington" <eric dot weddington at atmel dot com>, Anatoly Sokolov <aesok at post dot ru>, Denis Chertykov <chertykov at gmail dot com>
- Date: Wed, 15 Jun 2011 15:25:35 +0200
- Subject: [Patch, AVR]: Hack around PR34734
PR34734 is an annoying, false C++ warning for code like
const int x __attribute__((progmem)) = 1;
progmem.c:1:30: warning: only initialized variables can be placed into
program memory area [enabled by default]
The problem is that DECL_INITIAL is NULL at the specific point in
space and time (avr_handle_progmem_attribute) even though tree.def
promises otherwise.
The patch hacks around by explicitly querying for C++ front end.
Johann
--
PR target/34734
* config/avr/avr.c (avr_handle_progmem_attribute): Hack around
non-present DECL_INITIAL if front end is C++.
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c (Revision 175036)
+++ config/avr/avr.c (Arbeitskopie)
@@ -5099,7 +5099,15 @@ avr_handle_progmem_attribute (tree *node
}
else if (TREE_STATIC (*node) || DECL_EXTERNAL (*node))
{
- if (DECL_INITIAL (*node) == NULL_TREE && !DECL_EXTERNAL (*node))
+ if (DECL_INITIAL (*node) == NULL_TREE && !DECL_EXTERNAL (*node)
+ /* FIXME: Despite documentation in tree.def,
+ DECL_INITIAL is NULL if an initializer is
+ present in C++. This is presumably due to
+ different parsers for C resp. C++.
+ We hack around that annoying warning (PR34734)
+ by quering for the front end and emit a warning
+ just for non-C++. */
+ && NULL == strcasestr (lang_hooks.name, "c++"))
{
warning (0, "only initialized variables can be placed into "
"program memory area");