From patchwork Thu May 26 12:23:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 97571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B8C5FB6F73 for ; Thu, 26 May 2011 22:24:44 +1000 (EST) Received: (qmail 16459 invoked by alias); 26 May 2011 12:24:43 -0000 Received: (qmail 16447 invoked by uid 22791); 26 May 2011 12:24:42 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_05, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE 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, 26 May 2011 12:24:25 +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 post.strato.de (cohen mo62) (RZmta 25.18) with ESMTPA id v04cbdn4QC7w0x ; Thu, 26 May 2011 14:24:02 +0200 (MEST) Message-ID: <4DDE4657.7030206@gjlay.de> Date: Thu, 26 May 2011 14:23:51 +0200 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Eric Weddington , Anatoly Sokolov , Denis Chertykov Subject: [Patch, AVR, 4.6] PR target/44643 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. 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); + } } }