diff mbox series

[fortran] Pr87233 Constraint C1279 still followed after f2008 standard revision

Message ID e9eb9e13-18fb-d61e-de36-337638f6181c@charter.net
State New
Headers show
Series [fortran] Pr87233 Constraint C1279 still followed after f2008 standard revision | expand

Commit Message

Jerry DeLisle July 13, 2019, 11:54 p.m. UTC
Hi all,

The attached patch removes the subject constraint for gfortran default and 
-std=f2008/f2018. I had issues with repetitious errors. I tried to get rid of it 
using the e->error = 1 method useded later in the function, but that did not 
work, so I resorted to gfc_error_now which does the job.

Also modified one test case and added a new to cover this in the testsuite.

Regression tested on x86_64-pc-linux-gnu.

OK for trunk?

Regards,

Jerry

2019-07-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/87233
	* expr.c (check_restricted): Relax constraint C1279 which was
	removed from F2008 and above.

and

2019-07-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/87233
	* gfortran.dg/initialization_14.f90: Modify to now pass by
	remiving two dg-error commands. Added comments.
	* gfortran.dg/initialization_30.f90: New test that includes the
	two tests removed above with the 'dg-options -std=f95'.

Comments

Steve Kargl July 14, 2019, 12:09 a.m. UTC | #1
On Sat, Jul 13, 2019 at 04:54:07PM -0700, Jerry DeLisle wrote:
> Hi all,
> 
> The attached patch removes the subject constraint for gfortran default
> and -std=f2008/f2018. I had issues with repetitious errors. I tried
> to get rid of it using the e->error = 1 method useded later in the
> function, but that did not work, so I resorted to gfc_error_now which
> does the job.

You can suppress the error by looking at the error count with
gfc_get_error(&warning_cnt, &error_cnt).  If error_cnt == 0,
then issue the error; otherwise, simply return.

> 2019-07-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
> 
> 	PR fortran/87233
> 	* gfortran.dg/initialization_14.f90: Modify to now pass by
> 	remiving two dg-error commands. Added comments.

remiving?


OK.
Jerry DeLisle July 14, 2019, 11:03 p.m. UTC | #2
Could not get the use of gfc_get_errors to work right, it missed one of the 
errors in initialazation_30.f90. So I just did the deed.

Regards,

Jerry

Committing to svn+ssh://jvdelisle@gcc.gnu.org/svn/gcc/trunk ...
	A	gcc/testsuite/gfortran.dg/initialization_30.f90
	M	gcc/fortran/ChangeLog
	M	gcc/fortran/expr.c
	M	gcc/testsuite/ChangeLog
	M	gcc/testsuite/gfortran.dg/initialization_14.f90
Committed r273484
diff mbox series

Patch

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index ec9e3288b48..3b64b196c1b 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3305,11 +3305,13 @@  check_restricted (gfc_expr *e)
 	 restricted expression in an elemental procedure, it will have
 	 already been simplified away once we get here.  Therefore we
 	 don't need to jump through hoops to distinguish valid from
-	 invalid cases.  */
-      if (sym->attr.dummy && sym->ns == gfc_current_ns
+	 invalid cases.  Allowed in F2018.  */
+      if (gfc_notification_std (GFC_STD_F2008)
+	  && sym->attr.dummy && sym->ns == gfc_current_ns
 	  && sym->ns->proc_name && sym->ns->proc_name->attr.elemental)
 	{
-	  gfc_error ("Dummy argument %qs not allowed in expression at %L",
+	  gfc_error_now ("Dummy argument %qs not "
+		     "allowed in expression at %L",
 		     sym->name, &e->where);
 	  break;
 	}
diff --git a/gcc/testsuite/gfortran.dg/initialization_14.f90 b/gcc/testsuite/gfortran.dg/initialization_14.f90
index 4d5b6856cf0..aa1437719ac 100644
--- a/gcc/testsuite/gfortran.dg/initialization_14.f90
+++ b/gcc/testsuite/gfortran.dg/initialization_14.f90
@@ -3,18 +3,18 @@ 
 ! Dummy arguments are disallowed in initialization expressions in
 ! elemental functions except as arguments to the intrinsic functions
 ! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed
-! in 13.11.8
+! in 13.11.8 F95, likewise not allowed in F2003, now allowed in F2008.
 MODULE TT
 INTEGER M
 CONTAINS
    ELEMENTAL REAL FUNCTION two(N)
      INTEGER, INTENT(IN) :: N
-     INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
+     INTEGER, DIMENSION(N) :: scr ! Now valid under F2008
    END FUNCTION
 
    ELEMENTAL REAL FUNCTION twopointfive(N)
      INTEGER, INTENT(IN) :: N
-     INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
+     INTEGER, DIMENSION(MAX(N,2)) :: scr ! Now valid under F2008
    end FUNCTION twopointfive
 
    REAL FUNCTION three(N)
diff --git a/gcc/testsuite/gfortran.dg/initialization_30.f90 b/gcc/testsuite/gfortran.dg/initialization_30.f90
new file mode 100644
index 00000000000..ff8436bc7c9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/initialization_30.f90
@@ -0,0 +1,21 @@ 
+! { dg-do compile }
+! { dg-options "-std=f95" }
+! PR 20851
+! Dummy arguments are disallowed in initialization expressions in
+! elemental functions except as arguments to the intrinsic functions
+! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed
+! in 13.11.8
+MODULE TT
+INTEGER M
+CONTAINS
+   ELEMENTAL REAL FUNCTION two(N)
+     INTEGER, INTENT(IN) :: N
+     INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
+   END FUNCTION
+
+   ELEMENTAL REAL FUNCTION twopointfive(N)
+     INTEGER, INTENT(IN) :: N
+     INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
+   end FUNCTION twopointfive
+END MODULE
+END