From patchwork Tue Jul 17 08:13:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 171355 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 0BDB62C01BB for ; Tue, 17 Jul 2012 18:15:16 +1000 (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=1343117717; h=Comment: DomainKey-Signature: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=RvrcxUW YcikfMgjjeADo4Xz1nk4=; b=PC4s2zBSLPHe7kewl/AO3DvQIGL0CH3hIGKJFkK iaOI+DKg8hCV4FTEFvGqAECaxRDsGzGurJfA/ZcOnGcSWyD/AVfQ8rfyNmqKDe3z L7iL3L1CywH/Kpe49vlHkmZjMZ1zLt1bFalJnfhRdwwLyobyNIpuEXk9Htj5aEEh yclY= 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: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=pqMJHuqlXSrOf+d1MmrJztHxfo44dGG9AeMTOSNpYt8FiwCeybbuU3MYojS2IQ r7Ezwvp8KzQp8rB4Jb5kP6p0WFXcl3OJs84b+8i9DdenjdTxGTxifyZmql3tYYAu x55NUm0Sd/UWOOabdpy3mm+eQg8j3AlW9Jcw2lm8JVuMk=; Received: (qmail 26249 invoked by alias); 17 Jul 2012 08:14:43 -0000 Received: (qmail 26215 invoked by uid 22791); 17 Jul 2012 08:14:40 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jul 2012 08:14:26 +0000 Received: from [192.168.178.22] (port-92-204-53-225.dynamic.qsc.de [92.204.53.225]) by mx02.qsc.de (Postfix) with ESMTP id 095F627A88; Tue, 17 Jul 2012 10:13:58 +0200 (CEST) Message-ID: <50051EC2.5000802@net-b.de> Date: Tue, 17 Jul 2012 10:13:54 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR53985 add missing case to -Wc-binding-type 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 gfortran always warned for BIND(C) procedures if one used "integer", "integer(4)" etc. instead of "integer(c_int)". While the latter is surely more portable than the former, all of them are identical on nearly all systems. Hence, the other versions are rahter widely used. In order to reduce the clutter due to default warnings, since GCC 4.8 there is a new warning -Wc-binding-type, which is turned off by default. However, for some reason, it misses the most common case. That's now fixed in the attachment. I also corrected the wording. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2012-07-17 Tobias Burnus PR fortran/53985 * decl.c (gfc_verify_c_interop_param): Make warning conditional on -Wc-binding-type works and improve the wording. 2012-07-17 Tobias Burnus PR fortran/53985 * gfortran.dg/bind_c_usage_26.f90: New. * gfortran.dg/bind_c_procs.f03: Add dg-options "-Wc-binding-type". * gfortran.dg/bind_c_usage_13.f03: Ditto. * gfortran.dg/bind_c_usage_18.f90: Ditto. * gfortran.dg/interop_params.f03: Ditto. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index c3644b6..c6ba43e 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1027,8 +1032,8 @@ gfc_verify_c_interop_param (gfc_symbol *sym) "because it is polymorphic", sym->name, &(sym->declared_at), sym->ns->proc_name->name); - else - gfc_warning ("Variable '%s' at %L is a parameter to the " + else if (gfc_option.warn_c_binding_type) + gfc_warning ("Variable '%s' at %L is a dummy argument of the " "BIND(C) procedure '%s' but may not be C " "interoperable", sym->name, &(sym->declared_at), --- /dev/null 2012-07-17 07:28:04.995717470 +0200 +++ gcc/gcc/testsuite/gfortran.dg/bind_c_usage_26.f90 2012-07-17 09:05:56.000000000 +0200 @@ -0,0 +1,14 @@ +! { dg-do compile } +! +! PR fortran/53985 +! +! Check that the (default) -Wno-c-binding-type works +! and no warning is printed. +! +! With -Wc-binding-type, one gets: +! Warning: Variable 'x' at (1) is a dummy argument to the BIND(C) procedure +! 'test' but may not be C interoperable ) +! +subroutine test(x) bind(C) + integer :: x +end subroutine test diff --git a/gcc/testsuite/gfortran.dg/bind_c_procs.f03 b/gcc/testsuite/gfortran.dg/bind_c_procs.f03 index eaf0672..3bb6ea3 100644 --- a/gcc/testsuite/gfortran.dg/bind_c_procs.f03 +++ b/gcc/testsuite/gfortran.dg/bind_c_procs.f03 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-Wc-binding-type" } module bind_c_procs use, intrinsic :: iso_c_binding, only: c_int diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_13.f03 b/gcc/testsuite/gfortran.dg/bind_c_usage_13.f03 index d89963d..b8c2261 100644 --- a/gcc/testsuite/gfortran.dg/bind_c_usage_13.f03 +++ b/gcc/testsuite/gfortran.dg/bind_c_usage_13.f03 @@ -1,5 +1,5 @@ ! { dg-do compile } -! { dg-options "-fdump-tree-original" } +! { dg-options "-fdump-tree-original -Wc-binding-type" } ! ! PR fortran/34079 ! Character bind(c) arguments shall not pass the length as additional argument diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_18.f90 b/gcc/testsuite/gfortran.dg/bind_c_usage_18.f90 index 2bce215..ede9f60 100644 --- a/gcc/testsuite/gfortran.dg/bind_c_usage_18.f90 +++ b/gcc/testsuite/gfortran.dg/bind_c_usage_18.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-Wc-binding-type" } ! ! PR fortran/38160 ! diff --git a/gcc/testsuite/gfortran.dg/interop_params.f03 b/gcc/testsuite/gfortran.dg/interop_params.f03 index ea3dada..6eafba0 100644 --- a/gcc/testsuite/gfortran.dg/interop_params.f03 +++ b/gcc/testsuite/gfortran.dg/interop_params.f03 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-Wc-binding-type" } module interop_params use, intrinsic :: iso_c_binding