Message ID | 4D9DA1CF.4030707@gjlay.de |
---|---|
State | New |
Headers | show |
Georg-Johann Lay schrieb: > This is fix of PR44643 which is triggered 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. >
2011/4/11 Georg-Johann Lay <avr@gjlay.de>: > Georg-Johann Lay schrieb: >> This is fix of PR44643 which is triggered 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. >> Approved. Denis.
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); + } } }