public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Georg-Johann Lay <avr@gjlay.de>
To: gcc-patches@gcc.gnu.org
Cc: Denis Chertykov <chertykov@gmail.com>,
	 Eric Weddington <eric.weddington@atmel.com>,
	Anatoly Sokolov <aesok@post.ru>
Subject: [Patch, AVR, 4.6+trunk]: PR44643 addendum
Date: Thu, 30 Jun 2011 10:28:00 -0000	[thread overview]
Message-ID: <4E0C438A.8010604@gjlay.de> (raw)

[-- 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";
 

             reply	other threads:[~2011-06-30  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 10:28 Georg-Johann Lay [this message]
2011-07-04 10:21 ` Ping #1: " Georg-Johann Lay
2011-07-04 12:11   ` Denis Chertykov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E0C438A.8010604@gjlay.de \
    --to=avr@gjlay.de \
    --cc=aesok@post.ru \
    --cc=chertykov@gmail.com \
    --cc=eric.weddington@atmel.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).