public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch,AVR]: Fix PR target/44643
@ 2011-04-07 11:37 Georg-Johann Lay
  2011-04-11 11:12 ` Ping " Georg-Johann Lay
  0 siblings, 1 reply; 3+ messages in thread
From: Georg-Johann Lay @ 2011-04-07 11:37 UTC (permalink / raw)
  To: gcc-patches
  Cc: Anatoly Sokolov, Denis Chertykov, Eric Weddington, Joerg Wunsch

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

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.

[-- Attachment #2: pr44643.diff --]
[-- Type: text/x-patch, Size: 1215 bytes --]

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);
+        }
     }
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping [Patch,AVR]: Fix PR target/44643
  2011-04-07 11:37 [Patch,AVR]: Fix PR target/44643 Georg-Johann Lay
@ 2011-04-11 11:12 ` Georg-Johann Lay
  2011-04-12  5:39   ` Denis Chertykov
  0 siblings, 1 reply; 3+ messages in thread
From: Georg-Johann Lay @ 2011-04-11 11:12 UTC (permalink / raw)
  To: gcc-patches
  Cc: Anatoly Sokolov, Denis Chertykov, Eric Weddington, Joerg Wunsch

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping [Patch,AVR]: Fix PR target/44643
  2011-04-11 11:12 ` Ping " Georg-Johann Lay
@ 2011-04-12  5:39   ` Denis Chertykov
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Chertykov @ 2011-04-12  5:39 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: gcc-patches, Anatoly Sokolov, Eric Weddington, Joerg Wunsch

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-12  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-07 11:37 [Patch,AVR]: Fix PR target/44643 Georg-Johann Lay
2011-04-11 11:12 ` Ping " Georg-Johann Lay
2011-04-12  5:39   ` Denis Chertykov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).