From patchwork Tue Jan 3 15:38:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 134022 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 07FA1B6F99 for ; Wed, 4 Jan 2012 02:38:45 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326209926; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=5iQQbev Tuur7U0v2Hsp/16y6XKY=; b=mssJ0A62/X6d1ydysiW0dk1ifGtal7GkB/vvmLm i2LeFnTEaBbrQX6nH3i7cnqOSNcumA+6s9mi741kAvxjTX7wR7GqoHqS45JFEcXU bAacPrsslwSrjbZdH+BE7DmrmKQRi4AAow4KLv/dwVuefai8zOAyUoHeyNLh5KSA lB80= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=eQcHtYmA79e5YS6FE7N4gTvN+/k6+8efVWeZLlnDWh/8dMNia+lXaWNvMf9Z+O WkMxHMGM58tmRyDvzBOQUZJUrZHQEKOcCtDQ07BLsoSDH9LzH9sOpjxeH4v1M59M twQKGrDzVxj/On9gax0MGYHGgc1e0gKZ7nk3OYwa7f8t0=; Received: (qmail 22338 invoked by alias); 3 Jan 2012 15:38:37 -0000 Received: (qmail 22157 invoked by uid 22791); 3 Jan 2012 15:38:34 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Jan 2012 15:38:14 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id F1B56133EE; Tue, 3 Jan 2012 16:38:12 +0100 (CET) Received: from [192.168.0.106] (xdsl-78-35-190-65.netcologne.de [78.35.190.65]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id C492B11DBD; Tue, 3 Jan 2012 16:38:11 +0100 (CET) Message-ID: <4F0320E2.3090802@netcologne.de> Date: Tue, 03 Jan 2012 16:38:10 +0100 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, Fortran] Fix PR 49693, unused variable warnings in common blocks 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 Hello world, the attached patch fixes the PR by unconditionally disabling warnings about unused variables in common blocks. The reasons are outlined in the PR; there is quite a lot of unnecessary clutter caused by common blocks in module interfaces. Regression-tested. OK for trunk? Thomas 2012-01-03 Thomas Koenig PR fortran/49693 * trans-common.c (create_common): Mark variables as used to avoid warnings about unused variables in common blocks. 2012-01-03 Thomas Koenig PR fortran/49693 * gfortran.dg/common_17.f90: New test. ! { dg-do compile } ! { dg-options "-Wall" } ! PR fortran/49693 - this used to cause a spurious warning for the ! variable in the common block. ! Original test case by Stephan Kramer. module foo implicit none integer:: a common a end module foo ! { dg-final { cleanup-modules "foo" } } Index: trans-common.c =================================================================== --- trans-common.c (Revision 182754) +++ trans-common.c (Arbeitskopie) @@ -689,7 +689,9 @@ create_common (gfc_common_head *com, segment_info VAR_DECL, DECL_NAME (s->field), TREE_TYPE (s->field)); TREE_STATIC (var_decl) = TREE_STATIC (decl); - TREE_USED (var_decl) = TREE_USED (decl); + /* Mark the variable as used in order to avoid warnings about + unused variables. */ + TREE_USED (var_decl) = 1; if (s->sym->attr.use_assoc) DECL_IGNORED_P (var_decl) = 1; if (s->sym->attr.target)