summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0351-PR-target-44643.patch
blob: 18b150103f464230224792628234823aff39c8ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From b17f4e7b2f554537d075f35ad5d1b40419d119e8 Mon Sep 17 00:00:00 2001
From: gjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 26 May 2011 12:52:03 +0000
Subject: [PATCH] 	PR target/44643
 	* config/avr/avr.c (avr_insert_attributes): Leave TREE_READONLY
 	alone. Error if non-const data has attribute progmem.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174281 138bc75d-0d04-0410-961f-82ee72b054a4

index 92cc7b6..19b020b 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -4995,14 +4995,20 @@ avr_insert_attributes (tree node, tree *attributes)
       && (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);
-
-      /* ??? This seems sketchy.  Why can't the user declare the
-	 thing const in the first place?  */
-      TREE_READONLY (node) = 1;
+      if (TREE_READONLY (node)) 
+        {
+          static const char dsec[] = ".progmem.data";
+
+          *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);
+        }
     }
 }
 
-- 
1.7.0.4