@@ -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;
}
@@ -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)
new file mode 100644
@@ -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