public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR53985 add missing case to -Wc-binding-type
@ 2012-07-17  8:14 Tobias Burnus
  2012-07-17 19:10 ` Mikael Morin
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-07-17  8:14 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

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

[-- Attachment #2: bind-c-warning.diff --]
[-- Type: text/x-patch, Size: 3191 bytes --]

2012-07-17  Tobias Burnus  <burnus@net-b.de>

	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  <burnus@net-b.de>

	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
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, Fortran] PR53985 add missing case to -Wc-binding-type
  2012-07-17  8:14 [Patch, Fortran] PR53985 add missing case to -Wc-binding-type Tobias Burnus
@ 2012-07-17 19:10 ` Mikael Morin
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Morin @ 2012-07-17 19:10 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

On 17/07/2012 10:13, Tobias Burnus wrote:
> 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

OK, thanks.

Mikael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-17 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-17  8:14 [Patch, Fortran] PR53985 add missing case to -Wc-binding-type Tobias Burnus
2012-07-17 19:10 ` Mikael Morin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).