Instead of just swallowing dummies with VALUE and w/o INTENT in PURE
procedures, reject it for -std=f95/f2003.
Build and regtested on x86-64-linux
Tobias
PS:
pure-value-2.diff
2011-02-01 Tobias Burnus<burnus@net-b.de>
PR fortran/47550
* resolve.c (resolve_formal_arglist): PURE with VALUE
and no INTENT: Add -std= diagnostics.
2011-02-01 Tobias Burnus<burnus@net-b.de>
PR fortran/47550
* gfortran.dg/pure_formal_2.f90: New.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2a0fc49..25a3ad2 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -338,17 +338,31 @@ resolve_formal_arglist (gfc_symbol *proc)
if (gfc_pure (proc)&& !sym->attr.pointer
&& sym->attr.flavor != FL_PROCEDURE)
{
- if (proc->attr.function&& sym->attr.intent != INTENT_IN
- && !sym->attr.value)
- gfc_error ("Argument '%s' of pure function '%s' at %L must be "
- "INTENT(IN) or VALUE", sym->name, proc->name,
- &sym->declared_at);
+ if (proc->attr.function&& sym->attr.intent != INTENT_IN)
+ {
+ if (sym->attr.value)
+ gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Argument '%s' "
+ "of pure function '%s' at %L with VALUE "
+ "attribute but without INTENT(IN)", sym->name,
+ proc->name,&sym->declared_at);
+ else
+ gfc_error ("Argument '%s' of pure function '%s' at %L must be "
+ "INTENT(IN) or VALUE", sym->name, proc->name,
+ &sym->declared_at);
+ }
- if (proc->attr.subroutine&& sym->attr.intent == INTENT_UNKNOWN
- && !sym->attr.value)
- gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
+ if (proc->attr.subroutine&& sym->attr.intent == INTENT_UNKNOWN)
+ {
+ if (sym->attr.value)
+ gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Argument '%s' "
+ "of pure subroutine '%s' at %L with VALUE "
+ "attribute but without INTENT", sym->name,
+ proc->name,&sym->declared_at);
+ else
+ gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
"have its INTENT specified or have the VALUE "
"attribute", sym->name, proc->name,&sym->declared_at);
+ }
}
if (proc->attr.implicit_pure&& !sym->attr.pointer
--- /dev/null 2011-02-01 07:33:44.195999996 +0100
+++ gcc/gcc/testsuite/gfortran.dg/pure_formal_2.f90 2011-02-01 15:05:21.000000000 +0100
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! PR fortran/47550
+! Follow up to: PR fortran/47507
+!
+! PURE procedures: Allow arguments w/o INTENT if they are VALUE
+!
+
+pure function f(x) ! { dg-error "Fortran 2008: Argument 'x' of pure function" }
+ real, VALUE :: x
+ real :: f
+ f = sin(x)
+end function f
+
+pure subroutine sub(x) ! { dg-error "Fortran 2008: Argument 'x' of pure subroutine" }
+ real, VALUE :: x
+end subroutine sub