public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
@ 2014-08-19 13:13 Tobias Burnus
  2014-08-22 10:16 ` VandeVondele  Joost
  0 siblings, 1 reply; 15+ messages in thread
From: Tobias Burnus @ 2014-08-19 13:13 UTC (permalink / raw)
  To: VandeVondele Joost, fortran, gcc-patches, lopezibanez

VandeVondele Joost wrote:
> >> So the negative version is -Wno-use-no-only? That sounds weird.
> > What about -Wuse-without-only?
> 
> Would be fine with me. Approved with this change ?

That would be the patch: https://gcc.gnu.org/ml/fortran/2014-06/msg00114.html

> +Warn if a use statement has no only qualifier and thus implicitly imports
> +all public entities of the used module.

I would use "USE statement" or even "@code{USE} statement".


OK with the documentation change and with the re-named option. Please
also update the name in the code.


Regarding

+     USE foo, ONLY: bar ! { dg-bogus "has no ONLY qualifier" }
+  END SUBROUTINE
+  SUBROUTINE S3
+     USE ISO_C_BINDING ! { dg-warning "has no ONLY qualifier" }
+  END SUBROUTINE S3
+END MODULE
+! { dg-final { cleanup-modules "foo testmod" } }


The "cleanup module" shouldn't be needed as most of the time that
now happens automatically. And "dg-bogus" is also not really needed
as the code checks for excess errors and warnings. On the other hand,
it shouldn't do much harm either.

Thanks for the patch!

Regards,

Tobias

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-08-19 13:13 [PATCH, Fortran] PR61234: -Wuse-no-only Tobias Burnus
@ 2014-08-22 10:16 ` VandeVondele  Joost
  0 siblings, 0 replies; 15+ messages in thread
From: VandeVondele  Joost @ 2014-08-22 10:16 UTC (permalink / raw)
  To: Tobias Burnus, fortran, gcc-patches, lopezibanez

> OK with the documentation change and with the re-named option. Please
> also update the name in the code.

changes made and committed as r214311

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-08-19 11:41 Dominique Dhumieres
@ 2014-08-19 11:44 ` VandeVondele  Joost
  0 siblings, 0 replies; 15+ messages in thread
From: VandeVondele  Joost @ 2014-08-19 11:44 UTC (permalink / raw)
  To: Dominique Dhumieres, fortran; +Cc: gcc-patches, lopezibanez

>> So the negative version is -Wno-use-no-only? That sounds weird.

> What about -Wuse-without-only?

Would be fine with me. Approved with this change ?

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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
@ 2014-08-19 11:41 Dominique Dhumieres
  2014-08-19 11:44 ` VandeVondele  Joost
  0 siblings, 1 reply; 15+ messages in thread
From: Dominique Dhumieres @ 2014-08-19 11:41 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches, lopezibanez, joost.vandevondele

> So the negative version is -Wno-use-no-only? That sounds weird.

What about -Wuse-without-only?

I can also confirm that the test succeeds without the ' ! { dg-bogus "has no ONLY qualifier" }'.

Dominique

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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-08-18 15:51   ` VandeVondele  Joost
@ 2014-08-18 16:02     ` Manuel López-Ibáñez
  0 siblings, 0 replies; 15+ messages in thread
From: Manuel López-Ibáñez @ 2014-08-18 16:02 UTC (permalink / raw)
  To: VandeVondele Joost; +Cc: fortran, gcc-patches

On 18 August 2014 17:51, VandeVondele  Joost
<joost.vandevondele@mat.ethz.ch> wrote:
> ping ?
>
> https://gcc.gnu.org/ml/fortran/2014-06/msg00114.html

So the negative version is -Wno-use-no-only? That sounds weird.

Cheers,

Manuel.

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-06-10  7:14 ` VandeVondele  Joost
@ 2014-08-18 15:51   ` VandeVondele  Joost
  2014-08-18 16:02     ` Manuel López-Ibáñez
  0 siblings, 1 reply; 15+ messages in thread
From: VandeVondele  Joost @ 2014-08-18 15:51 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

ping ?

https://gcc.gnu.org/ml/fortran/2014-06/msg00114.html

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-06-10 10:09   ` Dominique Dhumieres
@ 2014-07-30 14:24     ` VandeVondele  Joost
  0 siblings, 0 replies; 15+ messages in thread
From: VandeVondele  Joost @ 2014-07-30 14:24 UTC (permalink / raw)
  To: Dominique Dhumieres, fortran; +Cc: jakub, gcc-patches

>> This explicitly tests that no bogus error message is issued
>> for a use statement that has an only qualifier ?
>
>I don't see the need for '! { dg-bogus "has no ONLY qualifier" }'.
>AFAICT there is no warning emitted for this line (unless you add -Wall)
>and if some day it happens that an error/warning is issued, the test will fail.
>
>Otherwise the new patch is OK for me.

if so, could the patch be applied by somebody with svn write permission (with or without the dg-bogus), fsf assignment is now OK.

Joost

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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-06-02  5:48 ` VandeVondele  Joost
@ 2014-06-10 10:09   ` Dominique Dhumieres
  2014-07-30 14:24     ` VandeVondele  Joost
  0 siblings, 1 reply; 15+ messages in thread
From: Dominique Dhumieres @ 2014-06-10 10:09 UTC (permalink / raw)
  To: joost.vandevondele, fortran, dominiq; +Cc: jakub, gcc-patches

> This explicitly tests that no bogus error message is issued
> for a use statement that has an only qualifier ?

I don't see the need for '! { dg-bogus "has no ONLY qualifier" }'.
AFAICT there is no warning emitted for this line (unless you add -Wall)
and if some day it happens that an error/warning is issued, the test will fail.

Otherwise the new patch is OK for me.

Cheers,

Dominique

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-05-30  8:03 VandeVondele  Joost
  2014-05-30  9:20 ` Jakub Jelinek
@ 2014-06-10  7:14 ` VandeVondele  Joost
  2014-08-18 15:51   ` VandeVondele  Joost
  1 sibling, 1 reply; 15+ messages in thread
From: VandeVondele  Joost @ 2014-06-10  7:14 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

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

Attached the reworked patch. The only change is that the warning is now not part of -Wall, given the consensus on the list.

The patch has been bootstrapped and regtested on x86_64-unknown-linux-gnu. If OK, please apply to trunk.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-Wuse-no-only-v04.diff --]
[-- Type: text/x-patch; name="patch-Wuse-no-only-v04.diff", Size: 4897 bytes --]

gcc/fortran/ChangeLog:

2014-06-04 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

        PR fortran/61234
        * lang.opt (Wuse-no-only): New flag.
        * gfortran.h (gfc_option_t): Add it.
        * invoke.texi: Document it.
        * module.c (gfc_use_module): Warn if needed.
        * options.c (gfc_init_options,gfc_handle_option): Init accordingly.

gcc/testsuite/ChangeLog:

2014-06-04 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

        * gfortran.dg/use_no_only_1.f90: New test.

Index: gcc/fortran/options.c
===================================================================
--- gcc/fortran/options.c	(revision 211094)
+++ gcc/fortran/options.c	(working copy)
@@ -105,6 +105,7 @@ gfc_init_options (unsigned int decoded_o
   gfc_option.warn_tabs = 1;
   gfc_option.warn_underflow = 1;
   gfc_option.warn_intrinsic_shadow = 0;
+  gfc_option.warn_use_no_only = 0;
   gfc_option.warn_intrinsics_std = 0;
   gfc_option.warn_align_commons = 1;
   gfc_option.warn_real_q_constant = 0;
@@ -730,6 +731,10 @@ gfc_handle_option (size_t scode, const c
       gfc_option.warn_intrinsic_shadow = value;
       break;
 
+    case OPT_Wuse_no_only:
+      gfc_option.warn_use_no_only = value;
+      break;
+
     case OPT_Walign_commons:
       gfc_option.warn_align_commons = value;
       break;
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h	(revision 211022)
+++ gcc/fortran/gfortran.h	(working copy)
@@ -2321,6 +2321,7 @@ typedef struct
   int warn_tabs;
   int warn_underflow;
   int warn_intrinsic_shadow;
+  int warn_use_no_only;
   int warn_intrinsics_std;
   int warn_character_truncation;
   int warn_array_temp;
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 211022)
+++ gcc/fortran/lang.opt	(working copy)
@@ -257,6 +257,10 @@ Wintrinsics-std
 Fortran Warning
 Warn on intrinsics not part of the selected standard
 
+Wuse-no-only
+Fortran Warning
+Warn about USE statements that have no only qualifier
+
 Wopenmp-simd
 Fortran
 ; Documented in C
Index: gcc/fortran/invoke.texi
===================================================================
--- gcc/fortran/invoke.texi	(revision 211022)
+++ gcc/fortran/invoke.texi	(working copy)
@@ -142,7 +142,7 @@ and warnings}.
 @gccoptlist{-Waliasing -Wall -Wampersand -Warray-bounds
 -Wc-binding-type -Wcharacter-truncation @gol
 -Wconversion -Wfunction-elimination -Wimplicit-interface @gol
--Wimplicit-procedure -Wintrinsic-shadow -Wintrinsics-std @gol
+-Wimplicit-procedure -Wintrinsic-shadow -Wuse-no-only -Wintrinsics-std @gol
 -Wline-truncation -Wno-align-commons -Wno-tabs -Wreal-q-constant @gol
 -Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
 -Wtarget-lifetime -fmax-errors=@var{n} -fsyntax-only -pedantic -pedantic-errors
@@ -896,6 +896,13 @@ intrinsic; in this case, an explicit int
 @code{INTRINSIC} declaration might be needed to get calls later resolved to
 the desired intrinsic/procedure.  This option is implied by @option{-Wall}.
 
+@item -Wuse-no-only
+@opindex @code{Wuse-no-only}
+@cindex warnings, use statements
+@cindex intrinsic
+Warn if a use statement has no only qualifier and thus implicitly imports
+all public entities of the used module.
+
 @item -Wunused-dummy-argument
 @opindex @code{Wunused-dummy-argument}
 @cindex warnings, unused dummy argument
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 211022)
+++ gcc/fortran/module.c	(working copy)
@@ -6398,6 +6398,9 @@ gfc_use_module (gfc_use_list *module)
   gfc_rename_list = module->rename;
   only_flag = module->only_flag;
 
+  if (!only_flag && gfc_option.warn_use_no_only) 
+    gfc_warning_now ("USE statement at %C has no ONLY qualifier");
+
   filename = XALLOCAVEC (char, strlen (module_name) + strlen (MODULE_EXTENSION)
 			       + 1);
   strcpy (filename, module_name);
Index: gcc/testsuite/gfortran.dg/use_no_only_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/use_no_only_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/use_no_only_1.f90	(revision 0)
@@ -0,0 +1,44 @@
+! PR fortran/61234 Warn for use-stmt without explicit only-list.
+! { dg-do compile }
+! { dg-options "-Wuse-no-only" }
+MODULE foo
+  INTEGER :: bar
+END MODULE
+
+MODULE testmod
+  USE foo ! { dg-warning "has no ONLY qualifier" }
+  IMPLICIT NONE
+CONTAINS
+  SUBROUTINE S1
+     USE foo ! { dg-warning "has no ONLY qualifier" }
+  END SUBROUTINE S1
+  SUBROUTINE S2
+     USE foo, ONLY: bar ! { dg-bogus "has no ONLY qualifier" }
+  END SUBROUTINE
+  SUBROUTINE S3
+     USE ISO_C_BINDING ! { dg-warning "has no ONLY qualifier" }
+  END SUBROUTINE S3
+END MODULE
+! { dg-final { cleanup-modules "foo testmod" } }

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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
@ 2014-06-02 20:08 FX
  0 siblings, 0 replies; 15+ messages in thread
From: FX @ 2014-06-02 20:08 UTC (permalink / raw)
  To: joost.vandevondele; +Cc: gfortran, gcc-patches

> I think it is really weird if a coding style warning is included in -Wall.

Same here. It’s not a very commonly shared coding style, so I don’t think it should be included in -Wall.
Other than that, I like the idea (but cannot review the patch).

FX

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-06-01  9:07 Dominique Dhumieres
@ 2014-06-02  5:48 ` VandeVondele  Joost
  2014-06-10 10:09   ` Dominique Dhumieres
  0 siblings, 1 reply; 15+ messages in thread
From: VandeVondele  Joost @ 2014-06-02  5:48 UTC (permalink / raw)
  To: Dominique Dhumieres, fortran; +Cc: gcc-patches, jakub

> What is the rationale of
>
> +  SUBROUTINE S2
> +     USE foo, ONLY: bar ! { dg-bogus "has no ONLY qualifier" }
> +  END SUBROUTINE

This explicitly tests that no bogus error message is issued for a use statement that has an only qualifier ?

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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
@ 2014-06-01  9:07 Dominique Dhumieres
  2014-06-02  5:48 ` VandeVondele  Joost
  0 siblings, 1 reply; 15+ messages in thread
From: Dominique Dhumieres @ 2014-06-01  9:07 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches, jakub, joost.vandevondele

> I think it is really weird if a coding style warning is included in -Wall.

I fully agree. In top of that the patch looks like a blind enforcement of this
coding style.

What is the rationale of

+  SUBROUTINE S2
+     USE foo, ONLY: bar ! { dg-bogus "has no ONLY qualifier" }
+  END SUBROUTINE

?

Cheers,

Dominique

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

* RE: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-05-30  9:20 ` Jakub Jelinek
@ 2014-05-30  9:32   ` VandeVondele  Joost
  0 siblings, 0 replies; 15+ messages in thread
From: VandeVondele  Joost @ 2014-05-30  9:32 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: fortran, gcc-patches

> I think it is really weird if a coding style warning is included in -Wall.

I have no strong opinion on this, I followed the -Wintrinsic-shadow example, and I'm happy to change things. 

Note however, that even the Fortran standard recommends the ONLY option for example for intrinsic modules, to guarantee that a program is portable to other processors and future versions of the standard, i.e. to avoid potential name conflicts (see Note 15.1 in F2003 standard).



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

* Re: [PATCH, Fortran] PR61234: -Wuse-no-only
  2014-05-30  8:03 VandeVondele  Joost
@ 2014-05-30  9:20 ` Jakub Jelinek
  2014-05-30  9:32   ` VandeVondele  Joost
  2014-06-10  7:14 ` VandeVondele  Joost
  1 sibling, 1 reply; 15+ messages in thread
From: Jakub Jelinek @ 2014-05-30  9:20 UTC (permalink / raw)
  To: VandeVondele Joost; +Cc: fortran, gcc-patches

On Fri, May 30, 2014 at 08:03:45AM +0000, VandeVondele  Joost wrote:
> +@item -Wuse-no-only
> +@opindex @code{Wuse-no-only}
> +@cindex warnings, use statements
> +@cindex intrinsic
> +Warn if a use statement has no only qualifier and thus implicitly imports
> +all public entities of the used module.
> +This option is implied by @option{-Wall}.

I think it is really weird if a coding style warning is included in -Wall.

	Jakub

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

* [PATCH, Fortran] PR61234: -Wuse-no-only
@ 2014-05-30  8:03 VandeVondele  Joost
  2014-05-30  9:20 ` Jakub Jelinek
  2014-06-10  7:14 ` VandeVondele  Joost
  0 siblings, 2 replies; 15+ messages in thread
From: VandeVondele  Joost @ 2014-05-30  8:03 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

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

Hi,

the attached patch fixes PR61234 by introducing a warning for modules used without an only qualifier, triggered by a flag '-Wuse-no-only'. 

It is a two line addition to module.c, plus mechanical changes to initialize the flag and keep the tests up-to-date. I currently have no copyright assignment filed, so I hope it can pass as 'trivial' or it needs to wait till I get the paperwork sorted.

The patch has been bootstrapped and regtested on x86_64-unknown-linux-gnu. If OK, please apply to trunk.

gcc/fortran/ChangeLog:

2014-05-29 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

        PR fortran/61234
        * lang.opt (Wuse-no-only): New flag.
        * gfortran.h (gfc_option_t): Add it.
        * invoke.texi: Document it.
        * module.c (gfc_use_module): Warn if needed.
        * options.c (gfc_init_options,set_Wall,gfc_handle_option): Init accordingly.

gcc/testsuite/ChangeLog:

2014-05-29 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

        * gfortran.dg/c_by_val_5.f90: Add expected -Wall warning.
        * gfortran.dg/transfer_check_4.f90: idem.
        * gfortran.dg/iso_c_binding_compiler_3.f90: idem.
        * gfortran.dg/pr52370.f90: idem.
        * gfortran.dg/use_no_only_1.f90: New test.

Thanks in advance,

Joost

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-Wuse-no-only-v02.diff --]
[-- Type: text/x-patch; name="patch-Wuse-no-only-v02.diff", Size: 8100 bytes --]

gcc/fortran/ChangeLog:

2014-05-29 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

        PR fortran/61234
        * lang.opt (Wuse-no-only): New flag.
        * gfortran.h (gfc_option_t): Add it.
        * invoke.texi: Document it.
        * module.c (gfc_use_module): Warn if needed.
        * options.c (gfc_init_options,set_Wall,gfc_handle_option): Init accordingly.

gcc/testsuite/ChangeLog:

2014-05-29 Joost VandeVondele  <Joost.VandeVondele@mat.ethz.ch>

	* gfortran.dg/c_by_val_5.f90: Add expected -Wall warning.
	* gfortran.dg/transfer_check_4.f90: idem.
	* gfortran.dg/iso_c_binding_compiler_3.f90: idem.
	* gfortran.dg/pr52370.f90: idem.
	* gfortran.dg/use_no_only_1.f90: New test.

Index: gcc/testsuite/gfortran.dg/c_by_val_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/c_by_val_5.f90	(revision 211022)
+++ gcc/testsuite/gfortran.dg/c_by_val_5.f90	(working copy)
@@ -59,7 +59,7 @@ END module x
 !end subroutine test
 
 program main
-  use x
+  use x ! { dg-warning "has no ONLY qualifier" }
   implicit none
 !  external test
   call Grid2BMP(10)
Index: gcc/testsuite/gfortran.dg/transfer_check_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/transfer_check_4.f90	(revision 211022)
+++ gcc/testsuite/gfortran.dg/transfer_check_4.f90	(working copy)
@@ -6,7 +6,7 @@
 
 subroutine transfers (test)
 
-  use, intrinsic :: iso_fortran_env
+  use, intrinsic :: iso_fortran_env ! { dg-warning "has no ONLY qualifier" }
   
   integer, intent(in) :: test
 
Index: gcc/testsuite/gfortran.dg/iso_c_binding_compiler_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/iso_c_binding_compiler_3.f90	(revision 211022)
+++ gcc/testsuite/gfortran.dg/iso_c_binding_compiler_3.f90	(working copy)
@@ -7,8 +7,8 @@
 !  "Type specified for intrinsic function" for this file
 !
 
-use iso_c_binding
-use iso_Fortran_env
+use iso_c_binding ! { dg-warning "has no ONLY qualifier" }
+use iso_Fortran_env ! { dg-warning "has no ONLY qualifier" }
 implicit none
 intrinsic sin
 real :: x = 3.4
@@ -17,9 +17,9 @@ end
 
 
 module test_mod
-    use iso_fortran_env
+    use iso_fortran_env ! { dg-warning "has no ONLY qualifier" }
 end module test_mod
 
 subroutine test
-use test_mod
+use test_mod ! { dg-warning "has no ONLY qualifier" }
 end subroutine test
Index: gcc/testsuite/gfortran.dg/use_no_only_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/use_no_only_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/use_no_only_1.f90	(revision 0)
@@ -0,0 +1,22 @@
+! PR fortran/61234 Warn for use-stmt without explicit only-list.
+! { dg-do compile }
+! { dg-options "-Wuse-no-only" }
+MODULE foo
+  INTEGER :: bar
+END MODULE
+
+MODULE testmod
+  USE foo ! { dg-warning "has no ONLY qualifier" }
+  IMPLICIT NONE
+CONTAINS
+  SUBROUTINE S1
+     USE foo ! { dg-warning "has no ONLY qualifier" }
+  END SUBROUTINE S1
+  SUBROUTINE S2
+     USE foo, ONLY: bar ! { dg-bogus "has no ONLY qualifier" }
+  END SUBROUTINE
+  SUBROUTINE S3
+     USE ISO_C_BINDING ! { dg-warning "has no ONLY qualifier" }
+  END SUBROUTINE S3
+END MODULE
+! { dg-final { cleanup-modules "foo testmod" } }
Index: gcc/testsuite/gfortran.dg/pr52370.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr52370.f90	(revision 211022)
+++ gcc/testsuite/gfortran.dg/pr52370.f90	(working copy)
@@ -15,7 +15,7 @@ contains
 end module pr52370
 
 program prg52370
-  use pr52370
+  use pr52370 ! { dg-warning "has no ONLY qualifier" }
   real :: a
   call foo(a)
 end program prg52370
Index: gcc/fortran/invoke.texi
===================================================================
--- gcc/fortran/invoke.texi	(revision 211022)
+++ gcc/fortran/invoke.texi	(working copy)
@@ -142,7 +142,7 @@ and warnings}.
 @gccoptlist{-Waliasing -Wall -Wampersand -Warray-bounds
 -Wc-binding-type -Wcharacter-truncation @gol
 -Wconversion -Wfunction-elimination -Wimplicit-interface @gol
--Wimplicit-procedure -Wintrinsic-shadow -Wintrinsics-std @gol
+-Wimplicit-procedure -Wintrinsic-shadow -Wuse-no-only -Wintrinsics-std @gol
 -Wline-truncation -Wno-align-commons -Wno-tabs -Wreal-q-constant @gol
 -Wsurprising -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
 -Wtarget-lifetime -fmax-errors=@var{n} -fsyntax-only -pedantic -pedantic-errors
@@ -729,7 +729,7 @@ we recommend avoiding and that we believ
 This currently includes @option{-Waliasing}, @option{-Wampersand},
 @option{-Wconversion}, @option{-Wsurprising}, @option{-Wc-binding-type},
 @option{-Wintrinsics-std}, @option{-Wno-tabs}, @option{-Wintrinsic-shadow},
-@option{-Wline-truncation}, @option{-Wtarget-lifetime},
+@option{-Wuse-no-only}, @option{-Wline-truncation}, @option{-Wtarget-lifetime},
 @option{-Wreal-q-constant} and @option{-Wunused}.
 
 @item -Waliasing
@@ -896,6 +896,14 @@ intrinsic; in this case, an explicit int
 @code{INTRINSIC} declaration might be needed to get calls later resolved to
 the desired intrinsic/procedure.  This option is implied by @option{-Wall}.
 
+@item -Wuse-no-only
+@opindex @code{Wuse-no-only}
+@cindex warnings, use statements
+@cindex intrinsic
+Warn if a use statement has no only qualifier and thus implicitly imports
+all public entities of the used module.
+This option is implied by @option{-Wall}.
+
 @item -Wunused-dummy-argument
 @opindex @code{Wunused-dummy-argument}
 @cindex warnings, unused dummy argument
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h	(revision 211022)
+++ gcc/fortran/gfortran.h	(working copy)
@@ -2321,6 +2321,7 @@ typedef struct
   int warn_tabs;
   int warn_underflow;
   int warn_intrinsic_shadow;
+  int warn_use_no_only;
   int warn_intrinsics_std;
   int warn_character_truncation;
   int warn_array_temp;
Index: gcc/fortran/options.c
===================================================================
--- gcc/fortran/options.c	(revision 211022)
+++ gcc/fortran/options.c	(working copy)
@@ -105,6 +105,7 @@ gfc_init_options (unsigned int decoded_o
   gfc_option.warn_tabs = 1;
   gfc_option.warn_underflow = 1;
   gfc_option.warn_intrinsic_shadow = 0;
+  gfc_option.warn_use_no_only = 0;
   gfc_option.warn_intrinsics_std = 0;
   gfc_option.warn_align_commons = 1;
   gfc_option.warn_real_q_constant = 0;
@@ -455,6 +456,7 @@ set_Wall (int setting)
   gfc_option.warn_tabs = !setting;
   gfc_option.warn_underflow = setting;
   gfc_option.warn_intrinsic_shadow = setting;
+  gfc_option.warn_use_no_only = setting;
   gfc_option.warn_intrinsics_std = setting;
   gfc_option.warn_character_truncation = setting;
   gfc_option.warn_real_q_constant = setting;
@@ -730,6 +732,10 @@ gfc_handle_option (size_t scode, const c
       gfc_option.warn_intrinsic_shadow = value;
       break;
 
+    case OPT_Wuse_no_only:
+      gfc_option.warn_use_no_only = value;
+      break;
+
     case OPT_Walign_commons:
       gfc_option.warn_align_commons = value;
       break;
Index: gcc/fortran/lang.opt
===================================================================
--- gcc/fortran/lang.opt	(revision 211022)
+++ gcc/fortran/lang.opt	(working copy)
@@ -257,6 +257,10 @@ Wintrinsics-std
 Fortran Warning
 Warn on intrinsics not part of the selected standard
 
+Wuse-no-only
+Fortran Warning
+Warn about USE statements that have no only qualifier
+
 Wopenmp-simd
 Fortran
 ; Documented in C
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 211022)
+++ gcc/fortran/module.c	(working copy)
@@ -6398,6 +6398,9 @@ gfc_use_module (gfc_use_list *module)
   gfc_rename_list = module->rename;
   only_flag = module->only_flag;
 
+  if (!only_flag && gfc_option.warn_use_no_only) 
+    gfc_warning_now ("USE statement at %C has no ONLY qualifier");
+
   filename = XALLOCAVEC (char, strlen (module_name) + strlen (MODULE_EXTENSION)
 			       + 1);
   strcpy (filename, module_name);

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

end of thread, other threads:[~2014-08-22 10:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 13:13 [PATCH, Fortran] PR61234: -Wuse-no-only Tobias Burnus
2014-08-22 10:16 ` VandeVondele  Joost
  -- strict thread matches above, loose matches on Subject: below --
2014-08-19 11:41 Dominique Dhumieres
2014-08-19 11:44 ` VandeVondele  Joost
2014-06-02 20:08 FX
2014-06-01  9:07 Dominique Dhumieres
2014-06-02  5:48 ` VandeVondele  Joost
2014-06-10 10:09   ` Dominique Dhumieres
2014-07-30 14:24     ` VandeVondele  Joost
2014-05-30  8:03 VandeVondele  Joost
2014-05-30  9:20 ` Jakub Jelinek
2014-05-30  9:32   ` VandeVondele  Joost
2014-06-10  7:14 ` VandeVondele  Joost
2014-08-18 15:51   ` VandeVondele  Joost
2014-08-18 16:02     ` Manuel López-Ibáñez

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).