From patchwork Mon Jun 20 13:45:34 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: 101127 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 75421B6FE1 for ; Mon, 20 Jun 2011 23:46:15 +1000 (EST) Received: (qmail 4054 invoked by alias); 20 Jun 2011 13:46:13 -0000 Received: (qmail 4033 invoked by uid 22791); 20 Jun 2011 13:46:11 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL, BAYES_00, 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.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Jun 2011 13:45:46 +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 (jimi mo19) (RZmta 25.18) with ESMTPA id C00fcan5KBeUHr ; Mon, 20 Jun 2011 15:45:37 +0200 (MEST) Message-ID: <4DFF4EFE.3080006@gjlay.de> Date: Mon, 20 Jun 2011 15:45:34 +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: Denis Chertykov , "Eric B. Weddington" , Anatoly Sokolov Subject: [Patch, AVR]: Fix PR34734 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 PR34734 produces annoying, false warnings if __attribute__((progmem)) is used in conjunction with C++. DECL_INITIAL is not yet set up in avr_handle_progmem_attribute. Johann PR target/34734 * config/avr/avr.c (avr_handle_progmem_attribute): Move warning about uninitialized data attributed 'progmem' from here... (avr_encode_section_info): ...to this new function. (TARGET_ENCODE_SECTION_INFO): New define. (avr_section_type_flags): For data in ".progmem.data", remove section flag SECTION_WRITE. Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 175201) +++ config/avr/avr.c (working copy) @@ -109,6 +109,7 @@ static void avr_function_arg_advance (cu static void avr_help (void); static bool avr_function_ok_for_sibcall (tree, tree); static void avr_asm_named_section (const char *name, unsigned int flags, tree decl); +static void avr_encode_section_info (tree, rtx, int); /* Allocate registers from r25 to r8 for parameters for function calls. */ #define FIRST_CUM_REG 26 @@ -200,6 +201,8 @@ static const struct attribute_spec avr_a #undef TARGET_ASM_INIT_SECTIONS #define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections +#undef TARGET_ENCODE_SECTION_INFO +#define TARGET_ENCODE_SECTION_INFO avr_encode_section_info #undef TARGET_REGISTER_MOVE_COST #define TARGET_REGISTER_MOVE_COST avr_register_move_cost @@ -5088,12 +5091,7 @@ avr_handle_progmem_attribute (tree *node } else if (TREE_STATIC (*node) || DECL_EXTERNAL (*node)) { - if (DECL_INITIAL (*node) == NULL_TREE && !DECL_EXTERNAL (*node)) - { - warning (0, "only initialized variables can be placed into " - "program memory area"); - *no_add_attrs = true; - } + *no_add_attrs = false; } else { @@ -5308,10 +5306,35 @@ avr_section_type_flags (tree decl, const ".noinit section"); } + if (0 == strncmp (name, ".progmem.data", strlen (".progmem.data"))) + flags &= ~SECTION_WRITE; + return flags; } +/* Implement `TARGET_ENCODE_SECTION_INFO'. */ + +static void +avr_encode_section_info (tree decl, rtx rtl ATTRIBUTE_UNUSED, + int new_decl_p) +{ + /* In avr_handle_progmem_attribute, DECL_INITIAL is not yet + readily available, see PR34734. So we postpone the warning + about uninitialized data in program memory section until here. */ + + if (new_decl_p + && decl && DECL_P (decl) + && NULL_TREE == DECL_INITIAL (decl) + && avr_progmem_p (decl, DECL_ATTRIBUTES (decl))) + { + warning (OPT_Wuninitialized, + "uninitialized variable %q+D put into " + "program memory area", decl); + } +} + + /* Implement `TARGET_ASM_FILE_START'. */ /* Outputs some appropriate text to go at the start of an assembler file. */