This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: *ping* Re: [Patch,Fortran] PR 47550 - add "Fortran 2008" -std= diagnostic for PURE + VALUE


On Fri, Feb 11, 2011 at 09:36:34PM +0100, Tobias Burnus wrote:
> 0.5 * ping

Whoops. I thought you had committed this.  See 
some style issues below.  OK to commit after
addressing comments.

> On 8 February 2011,Tobias Burnus wrote:
> >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

Space before &&

> >  	&&  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)

Likewise.

> >+	    {
> >+	      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)", 

See below.

> >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)

Space before &&.

> >+	    {
> >+	      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,

INTENT(IN)?  See above message.  Are the intent requirements
different for functions and subroutines?

> >+				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

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]