From patchwork Wed Apr 19 10:43:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 752204 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w7JWH495Hz9s0g for ; Wed, 19 Apr 2017 20:43:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MVZCt5Sa"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=GzXfgZSfwT1eBADbaGv3cSb3HvaZffTIfo0g/oChjVfsY1HemI D+DgOUgL2RSCkJbfe4085DkXuekSGeEtZbaBGR6Di0PEla90oh1ghr+BO0hsxGsl bP1I8QQYrolRHD6TtTUJEargUloXRTsgkkkAYxKKcsT3fXNNS4I/JLWUk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=NW2ypHo3VNMWL2ms3qnxm7PgRyE=; b=MVZCt5SajFK9IAIXsj0e r5YPYVBmLN9wJCh2FJbOcFlkEweWIR54xcmNen/Py3v+hSgkth7GUzuXNNmrWd4E Qi7xMo43DpV99QVkODik63ACpvf/ovtbA3Cb9uw0BXvMIHgfty446TdDKtcTBTc7 RrwU5fZqXCQcKuy6MBlChPQ= Received: (qmail 92102 invoked by alias); 19 Apr 2017 10:43:07 -0000 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 Received: (qmail 92063 invoked by uid 89); 19 Apr 2017 10:43:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.160) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 10:43:03 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwR/bcHRirORRW3yMcVao= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (mail.hightec-rt.com [213.135.1.215]) by smtp.strato.de (RZmta 40.4 DYNA|AUTH) with ESMTPSA id L062d8t3JAh130S (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 19 Apr 2017 12:43:01 +0200 (CEST) To: gcc-patches Cc: Denis Chertykov , Senthil Kumar Selvaraj From: Georg-Johann Lay Subject: [patch,avr] Fix PR80462 Message-ID: <33edbd36-e09f-63d4-7b5f-1eb149c17a78@gjlay.de> Date: Wed, 19 Apr 2017 12:43:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 X-IsSubscribed: yes This PR is about an incorrect warning for variables in progmem without initializer. If the variable is just an alias like in and with -fmerge-all-constants const __flash char string1[] = "same string"; const __flash char string2[] = "same string"; this will result in an incorrect warning: uninitialized variable 'string2' put into program memory area [-Wuninitialized] Hence, this patch tests whether the decl is just an alias. Ok to apply? Johann PR target/80462 * config/avr/avr.c (tree.h): Include it. (cgraph.h): Include it. (avr_encode_section_info): Don't warn for uninitialized progmem variable if it's just an alias. Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 246966) +++ config/avr/avr.c (working copy) @@ -25,6 +25,8 @@ #include "backend.h" #include "target.h" #include "rtl.h" +#include "tree.h" +#include "cgraph.h" #include "c-family/c-common.h" #include "cfghooks.h" #include "df.h" @@ -10127,9 +10129,14 @@ avr_encode_section_info (tree decl, rtx && !DECL_EXTERNAL (decl) && avr_progmem_p (decl, DECL_ATTRIBUTES (decl))) { - warning (OPT_Wuninitialized, - "uninitialized variable %q+D put into " - "program memory area", decl); + // Don't warn for (implicit) aliases like in PR80462. + tree asmname = DECL_ASSEMBLER_NAME (decl); + varpool_node *node = varpool_node::get_for_asmname (asmname); + bool alias_p = node && node->alias; + + if (!alias_p) + warning (OPT_Wuninitialized, "uninitialized variable %q+D put into " + "program memory area", decl); } default_encode_section_info (decl, rtl, new_decl_p);