This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch,AVR]: Fix PR target/44643
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Anatoly Sokolov <aesok at post dot ru>, Denis Chertykov <chertykov at gmail dot com>, Eric Weddington <eric dot weddington at atmel dot com>, Joerg Wunsch <joerg_wunsch at uriah dot heep dot sax dot de>
- Date: Thu, 07 Apr 2011 13:36:47 +0200
- Subject: [Patch,AVR]: Fix PR target/44643
This is fix of PR44643 which is triggerd by
http://savannah.nongnu.org/bugs/?32988
i.e. include/avr/pgmspace.h:PSTR has to be changed, too: PSTR has to
generate __c as "static const char[]", not as "static char[]". Note
that avr-libc has to be changed anyway, no matter if or if not this
patch is applied or not.
2011-04-07 Georg-Johann Lay <avr@gjlay.de>
PR target/44643
* config/avr/avr.c (avr_insert_attributes): Error if non-const
data has attribute progmem.
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c (Revision 172046)
+++ config/avr/avr.c (Arbeitskopie)
@@ -5149,14 +5149,20 @@ avr_insert_attributes (tree node, tree *
&& (TREE_STATIC (node) || DECL_EXTERNAL (node))
&& avr_progmem_p (node, *attributes))
{
- static const char dsec[] = ".progmem.data";
- *attributes = tree_cons (get_identifier ("section"),
- build_tree_list (NULL, build_string (strlen (dsec), dsec)),
- *attributes);
+ if (TREE_READONLY (node))
+ {
+ static const char dsec[] = ".progmem.data";
- /* ??? This seems sketchy. Why can't the user declare the
- thing const in the first place? */
- TREE_READONLY (node) = 1;
+ *attributes = tree_cons (get_identifier ("section"),
+ build_tree_list (NULL, build_string (strlen (dsec), dsec)),
+ *attributes);
+ }
+ else
+ {
+ error ("variable %q+D must be const in order to be put into"
+ " read-only section by means of %<__attribute__((progmem))%>",
+ node);
+ }
}
}