diff mbox

[AVR,4.6] PR target/44643

Message ID 4DDE4657.7030206@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay May 26, 2011, 12:23 p.m. UTC
This is a straight forward 4.7 -> 4.6 backport for PR44643

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00544.html
http://gcc.gnu.org/viewcvs?view=revision&revision=172415


Johann

PR target/44643
	* config/avr/avr.c (avr_insert_attributes): Leave TREE_READONLY
	alone. Error if non-const data has attribute progmem.

Comments

Weddington, Eric May 26, 2011, 12:42 p.m. UTC | #1
> -----Original Message-----
> From: Georg-Johann Lay [mailto:avr@gjlay.de]
> Sent: Thursday, May 26, 2011 6:24 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Weddington, Eric; Anatoly Sokolov; Denis Chertykov
> Subject: [Patch, AVR, 4.6] PR target/44643
> 
> This is a straight forward 4.7 -> 4.6 backport for PR44643
> 
> http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00544.html
> http://gcc.gnu.org/viewcvs?view=revision&revision=172415
> 
> 
> Johann
> 
> PR target/44643
> 	* config/avr/avr.c (avr_insert_attributes): Leave TREE_READONLY
> 	alone. Error if non-const data has attribute progmem.

Looks good to me. Please commit.

Eric
diff mbox

Patch

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(Revision 174269)
+++ config/avr/avr.c	(Arbeitskopie)
@@ -4995,14 +4995,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);
+        }
     }
 }