diff mbox

[Fortran] PR 47507 - allow PURE functions with intent-free VALUE dummies; update to gfortran.texi

Message ID 4D42F174.2080301@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Jan. 28, 2011, 4:40 p.m. UTC
Two simple patches:
- Small update to the F2003 status in the documentation
- Allow for PURE procedures dummy arguments which are merely VALUE and 
have no intent.

Cf. F2003's
C1276 The specification-part of a pure function subprogram shall specify 
that all its nonpointer dummy data objects have the INTENT (IN) or the 
VALUE attribute.
C1277 The specification-part of a pure subroutine subprogram shall 
specify the intents of all its nonpointer dummy data objects that do not 
have the VALUE attribute.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias

Comments

Jerry DeLisle Jan. 28, 2011, 7:44 p.m. UTC | #1
On 01/28/2011 08:40 AM, Tobias Burnus wrote:
> Two simple patches:
> - Small update to the F2003 status in the documentation
> - Allow for PURE procedures dummy arguments which are merely VALUE and have no
> intent.
>
> Cf. F2003's
> C1276 The specification-part of a pure function subprogram shall specify that
> all its nonpointer dummy data objects have the INTENT (IN) or the VALUE attribute.
> C1277 The specification-part of a pure subroutine subprogram shall specify the
> intents of all its nonpointer dummy data objects that do not have the VALUE
> attribute.
>
> Build and regtested on x86-64-linux.
> OK for the trunk?
>
This is OK. Thanks!

Jerry
diff mbox

Patch

2011-01-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/47507
	* resolve.c (resolve_formal_arglist): Allow arguments with VALUE
	attribute also without INTENT.

2011-01-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/47507
	* gfortran.dg/pure_formal_1.f90: New.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2436283..55b5183 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -338,15 +338,17 @@  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)
+	  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)", sym->name, proc->name,
+		       "INTENT(IN) or VALUE", sym->name, proc->name,
 		       &sym->declared_at);
 
-	  if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN)
+	  if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN
+	      && !sym->attr.value)
 	    gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
-		       "have its INTENT specified", sym->name, proc->name,
-		       &sym->declared_at);
+		       "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-01-28 07:54:23.859999997 +0100
+++ gcc/gcc/testsuite/gfortran.dg/pure_formal_1.f90	2011-01-28 17:03:50.000000000 +0100
@@ -0,0 +1,16 @@ 
+! { dg-do compile }
+!
+! PR fortran/47507
+!
+! PURE procedures: Allow arguments w/o INTENT if they are VALUE
+!
+
+pure function f(x)
+  real, VALUE :: x
+  real :: f
+  f = sin(x)
+end function f
+
+pure subroutine sub(x)
+  real, VALUE :: x
+end subroutine sub