diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2019-08-05 00:47:41 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2019-08-05 00:47:41 +0000 |
commit | 7f9f93b51d59f43f362b3f66ecd8503390d1cfde (patch) | |
tree | 886ca84829857a032ffceb0dded0d6479b9bcfe3 | |
parent | 952f2fc25b8de168ef24bc05d65b062432727df0 (diff) |
2019-08-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Backport from trunk
PR fortran/87233
* expr.c (check_restricted): Relax constraint C1279 which was
removed from F2008 and above.
* gfortran.dg/initialization_14.f90: Modify to now pass by
removing 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'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@274104 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/initialization_14.f90 | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/initialization_30.f90 | 21 |
5 files changed, 45 insertions, 6 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c7162f19b73..02fef6255ac 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-08-04 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + Backport from trunk + PR fortran/87233 + * expr.c (check_restricted): Relax constraint C1279 which was + removed from F2008 and above. + 2019-07-30 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/91296 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 4579d82501f..2aeea92b8fb 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/ChangeLog b/gcc/testsuite/ChangeLog index 54732fe7ce3..52dac078b69 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-08-04 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + Backport from mainline. + PR fortran/87233 + * gfortran.dg/initialization_14.f90: Modify to now pass by + removing 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'. + 2019-08-04 Iain Sandoe <iain@sandoe.co.uk> Backport from mainline. 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 |