diff mbox series

[Fortran] PR 85849: [F2018] warn for obsolescent features

Message ID CAKwh3qgK11qNDbt48vCEOd33pwZS77_JsUXA1UYWK7FsHsVtBw@mail.gmail.com
State New
Headers show
Series [Fortran] PR 85849: [F2018] warn for obsolescent features | expand

Commit Message

Janus Weil May 24, 2018, 7:57 p.m. UTC
Hi all,

just because 2018 seems like a good time to do that, I continue
plucking some of the low-hanging Fortran 2018 fruit. The attached
patch adds obsolescence warnings for all major F18 obsolescences
(COMMON, BLOCK DATA, EQUIVALENCE, FORALL, labeled DO). Those warnings
appear only with -std=f2018, but not with gfortran's default -std=gnu.
They currently have zero impact on the gfortran test suite, so I'm
adding a new test case to check for their existence.

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2018-05-24  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/85839
    * match.c (gfc_match_block_data): Call gfc_notify_std to warn about
    an obsolescent feature in Fortran 2018.
    (gfc_match_equivalence): Ditto.
    * resolve.c (resolve_common_blocks): Ditto.
    (gfc_resolve_forall): Ditto.
    * symbol.c (gfc_define_st_label): Ditto.


2018-05-24  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/85839
    * gfortran.dg/f2018_obs.f90: New test case.

Comments

Steve Kargl May 24, 2018, 8:59 p.m. UTC | #1
On Thu, May 24, 2018 at 09:57:16PM +0200, Janus Weil wrote:
> 
> just because 2018 seems like a good time to do that, I continue
> plucking some of the low-hanging Fortran 2018 fruit. The attached
> patch adds obsolescence warnings for all major F18 obsolescences
> (COMMON, BLOCK DATA, EQUIVALENCE, FORALL, labeled DO). Those warnings
> appear only with -std=f2018, but not with gfortran's default -std=gnu.
> They currently have zero impact on the gfortran test suite, so I'm
> adding a new test case to check for their existence.
> 
> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
> 

Ok.  Thanks for housekeeping type patches.
Janus Weil May 25, 2018, 6:09 a.m. UTC | #2
2018-05-24 22:59 GMT+02:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Thu, May 24, 2018 at 09:57:16PM +0200, Janus Weil wrote:
>>
>> just because 2018 seems like a good time to do that, I continue
>> plucking some of the low-hanging Fortran 2018 fruit. The attached
>> patch adds obsolescence warnings for all major F18 obsolescences
>> (COMMON, BLOCK DATA, EQUIVALENCE, FORALL, labeled DO). Those warnings
>> appear only with -std=f2018, but not with gfortran's default -std=gnu.
>> They currently have zero impact on the gfortran test suite, so I'm
>> adding a new test case to check for their existence.
>>
>> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>>
>
> Ok.  Thanks for housekeeping type patches.

Thanks! Committed as r260705.

Cheers,
Janus
diff mbox series

Patch

Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c	(revision 260623)
+++ gcc/fortran/match.c	(working copy)
@@ -5259,6 +5259,10 @@  gfc_match_block_data (void)
   gfc_symbol *sym;
   match m;
 
+  if (!gfc_notify_std (GFC_STD_F2018_OBS, "BLOCK DATA construct at %L",
+      &gfc_current_locus))
+    return MATCH_ERROR;
+
   if (gfc_match_eos () == MATCH_YES)
     {
       gfc_new_block = NULL;
@@ -5575,6 +5579,9 @@  gfc_match_equivalence (void)
 	}
     }
 
+  if (!gfc_notify_std (GFC_STD_F2018_OBS, "EQUIVALENCE statement at %C"))
+    return MATCH_ERROR;
+
   return MATCH_YES;
 
 syntax:
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 260623)
+++ gcc/fortran/resolve.c	(working copy)
@@ -997,6 +997,10 @@  resolve_common_blocks (gfc_symtree *common_root)
 
   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.  */
@@ -9928,6 +9932,9 @@  gfc_resolve_forall (gfc_code *code, gfc_namespace
 
   old_nvar = nvar;
 
+  if (!gfc_notify_std (GFC_STD_F2018_OBS, "FORALL construct at %L", &code->loc))
+    return;
+
   /* Start to resolve a FORALL construct   */
   if (forall_save == 0)
     {
Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 260623)
+++ gcc/fortran/symbol.c	(working copy)
@@ -2725,6 +2725,10 @@  gfc_define_st_label (gfc_st_label *lp, gfc_sl_type
 				  "DO termination statement which is not END DO"
 				  " or CONTINUE with label %d at %C", labelno))
 	    return;
+	  if (type == ST_LABEL_DO_TARGET
+	      && !gfc_notify_std (GFC_STD_F2018_OBS, "Labeled DO statement "
+				  "at %L", label_locus))
+	    return;
 	  break;
 
 	default: