public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, AVR, 4.6+trunk]: PR44643 addendum
@ 2011-06-30 10:28 Georg-Johann Lay
  2011-07-04 10:21 ` Ping #1: " Georg-Johann Lay
  0 siblings, 1 reply; 3+ messages in thread
From: Georg-Johann Lay @ 2011-06-30 10:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Denis Chertykov, Eric Weddington, Anatoly Sokolov

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

avr_insert_attributes uses TREE_READONLY on get readonlyness of node.

That does not work for C++ arrays: it gives false error
"variable must be const in order to be put into read-only section by
means of '__attribute__((progmem))'".

This patch peels arrays and uses TYPE_READONLY.

I did not open separate PR for this, tagged it as addendum to PR44643
instead.

Lightly tested on own code. There is no 'progmem' in testsuite, so
from testsuite's perspective that code is dead, anyway...

Johann

	PR target/44643
	* config/avr/avr.c (avr_insert_attributes): Use TYPE_READONLY
	instead of TREE_READONLY.

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

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 175629)
+++ config/avr/avr.c	(working copy)
@@ -5030,7 +5030,19 @@ avr_insert_attributes (tree node, tree *
       && (TREE_STATIC (node) || DECL_EXTERNAL (node))
       && avr_progmem_p (node, *attributes))
     {
-      if (TREE_READONLY (node)) 
+      tree node0 = node;
+
+      /* For C++, we have to peel arrays in order to get correct
+         determination of readonlyness.  */
+      
+      do
+        node0 = TREE_TYPE (node0);
+      while (TREE_CODE (node0) == ARRAY_TYPE);
+
+      if (error_mark_node == node0)
+        return;
+      
+      if (TYPE_READONLY (node0))
         {
           static const char dsec[] = ".progmem.data";
 

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

* Ping #1: [Patch, AVR, 4.6+trunk]: PR44643 addendum
  2011-06-30 10:28 [Patch, AVR, 4.6+trunk]: PR44643 addendum Georg-Johann Lay
@ 2011-07-04 10:21 ` Georg-Johann Lay
  2011-07-04 12:11   ` Denis Chertykov
  0 siblings, 1 reply; 3+ messages in thread
From: Georg-Johann Lay @ 2011-07-04 10:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Denis Chertykov, Eric Weddington, Anatoly Sokolov

Georg-Johann Lay wrote:

http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02318.html

> avr_insert_attributes uses TREE_READONLY on get readonlyness of node.
> 
> That does not work for C++ arrays: it gives false error
> "variable must be const in order to be put into read-only section by
> means of '__attribute__((progmem))'".
> 
> This patch peels arrays and uses TYPE_READONLY.
> 
> I did not open separate PR for this, tagged it as addendum to PR44643
> instead.
> 
> Lightly tested on own code. There is no 'progmem' in testsuite, so
> from testsuite's perspective that code is dead, anyway...
> 
> Johann
> 
> 	PR target/44643
> 	* config/avr/avr.c (avr_insert_attributes): Use TYPE_READONLY
> 	instead of TREE_READONLY.
> 

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

* Re: Ping #1: [Patch, AVR, 4.6+trunk]: PR44643 addendum
  2011-07-04 10:21 ` Ping #1: " Georg-Johann Lay
@ 2011-07-04 12:11   ` Denis Chertykov
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Chertykov @ 2011-07-04 12:11 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Eric Weddington, Anatoly Sokolov

2011/7/4 Georg-Johann Lay <avr@gjlay.de>:
> Georg-Johann Lay wrote:
>
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02318.html
>
>> avr_insert_attributes uses TREE_READONLY on get readonlyness of node.
>>
>> That does not work for C++ arrays: it gives false error
>> "variable must be const in order to be put into read-only section by
>> means of '__attribute__((progmem))'".
>>
>> This patch peels arrays and uses TYPE_READONLY.
>>
>> I did not open separate PR for this, tagged it as addendum to PR44643
>> instead.
>>
>> Lightly tested on own code. There is no 'progmem' in testsuite, so
>> from testsuite's perspective that code is dead, anyway...
>>
>> Johann
>>
>>       PR target/44643
>>       * config/avr/avr.c (avr_insert_attributes): Use TYPE_READONLY
>>       instead of TREE_READONLY.

Approved.

Denis.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 10:28 [Patch, AVR, 4.6+trunk]: PR44643 addendum Georg-Johann Lay
2011-07-04 10:21 ` Ping #1: " Georg-Johann Lay
2011-07-04 12:11   ` 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).