diff mbox series

[PR,fortran/88299] - [F18] COMMON in a legacy module produces bogus warnings in dependent code

Message ID 5C61F28C.1070002@gmx.de
State New
Headers show
Series [PR,fortran/88299] - [F18] COMMON in a legacy module produces bogus warnings in dependent code | expand

Commit Message

Harald Anlauf Feb. 11, 2019, 10:09 p.m. UTC
The attached patch moves the check for this F2018 obsolescent feature
to a better place where the warning is only emitted when the COMMON is
declared.  No warning should be emitted when such a legacy module is
simply used.

Regtested on x86_64-pc-linux-gnu.

OK for trunk?

Thanks,
Harald

2019-02-11  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/88299
	* resolve.c (resolve_common_blocks,resolve_common_vars): Move
	check for obsolent COMMON feature in F2018 to better place.

2019-02-11  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/88299
	* gfortran.dg/pr88299.f90: New test.

Index: gcc/testsuite/gfortran.dg/pr88299.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr88299.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr88299.f90	(working copy)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+!
+! PR 85839: [F18] COMMON in a legacy module produces bogus warnings
+!           in dependent code
+
+module legacy
+  integer :: major, n
+  common /version/ major  ! { dg-warning "obsolescent feature" }
+  public  :: n
+  private
+end module legacy
+
+module mod1
+  use legacy, only: n     ! No warning expected here
+end module mod1

Comments

Harald Anlauf Feb. 17, 2019, 7:41 p.m. UTC | #1
Ping!

On 02/11/19 23:09, Harald Anlauf wrote:
> The attached patch moves the check for this F2018 obsolescent feature
> to a better place where the warning is only emitted when the COMMON is
> declared.  No warning should be emitted when such a legacy module is
> simply used.
> 
> Regtested on x86_64-pc-linux-gnu.
> 
> OK for trunk?
> 
> Thanks,
> Harald
> 
> 2019-02-11  Harald Anlauf  <anlauf@gmx.de>
> 
> 	PR fortran/88299
> 	* resolve.c (resolve_common_blocks,resolve_common_vars): Move
> 	check for obsolent COMMON feature in F2018 to better place.
> 
> 2019-02-11  Harald Anlauf  <anlauf@gmx.de>
> 
> 	PR fortran/88299
> 	* gfortran.dg/pr88299.f90: New test.
> 

Regards,
Harald
Thomas Koenig Feb. 17, 2019, 8:40 p.m. UTC | #2
Hi Harald,

> Ping!

> On 02/11/19 23:09, Harald Anlauf wrote:
>> The attached patch moves the check for this F2018 obsolescent feature
>> to a better place where the warning is only emitted when the COMMON is
>> declared.  No warning should be emitted when such a legacy module is
>> simply used.
>>
>> Regtested on x86_64-pc-linux-gnu.
>>
>> OK for trunk?


OK.

Thanks for the patch!

Regards

	Thomas
Harald Anlauf Feb. 17, 2019, 9:20 p.m. UTC | #3
Committed as rev. 268974.

Thanks for the review!

Harald

On 02/17/19 21:40, Thomas Koenig wrote:
> Hi Harald,
> 
>> Ping!
> 
>> On 02/11/19 23:09, Harald Anlauf wrote:
>>> The attached patch moves the check for this F2018 obsolescent feature
>>> to a better place where the warning is only emitted when the COMMON is
>>> declared.  No warning should be emitted when such a legacy module is
>>> simply used.
>>>
>>> Regtested on x86_64-pc-linux-gnu.
>>>
>>> OK for trunk?
> 
> 
> OK.
> 
> Thanks for the patch!
> 
> Regards
> 
>     Thomas
>
diff mbox series

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 268778)
+++ gcc/fortran/resolve.c	(working copy)
@@ -940,7 +940,11 @@ 
 	 have been ignored to continue parsing.
 	 We do the checks again here.  */
       if (!csym->attr.use_assoc)
-	gfc_add_in_common (&csym->attr, csym->name, &common_block->where);
+	{
+	  gfc_add_in_common (&csym->attr, csym->name, &common_block->where);
+	  gfc_notify_std (GFC_STD_F2018_OBS, "COMMON block at %L",
+			  &common_block->where);
+	}
 
       if (csym->value || csym->attr.data)
 	{
@@ -998,10 +1002,6 @@ 
 
   resolve_common_vars (common_root->n.common, true);
 
-  if (!gfc_notify_std (GFC_STD_F2018_OBS, "COMMON block at %L",
-		       &common_root->n.common->where))
-    return;
-
   /* The common name is a global name - in Fortran 2003 also if it has a
      C binding name, since Fortran 2008 only the C binding name is a global
      identifier.  */