From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2857 invoked by alias); 30 Jun 2011 09:36:51 -0000 Received: (qmail 2704 invoked by uid 22791); 30 Jun 2011 09:36:50 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.160) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 09:36:17 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by smtp.strato.de (jimi mo12) (RZmta 26.0) with ESMTPA id N0311dn5U8M2Qd ; Thu, 30 Jun 2011 11:36:10 +0200 (MEST) Message-ID: <4E0C438A.8010604@gjlay.de> Date: Thu, 30 Jun 2011 10:28:00 -0000 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Denis Chertykov , Eric Weddington , Anatoly Sokolov Subject: [Patch, AVR, 4.6+trunk]: PR44643 addendum Content-Type: multipart/mixed; boundary="------------070801090606090507040804" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg02322.txt.bz2 This is a multi-part message in MIME format. --------------070801090606090507040804 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 605 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. --------------070801090606090507040804 Content-Type: text/x-patch; name="pr44643-peel.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pr44643-peel.diff" Content-length: 779 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"; --------------070801090606090507040804--