From patchwork Tue Feb 8 22:11:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Fortran] PR 47550 - add "Fortran 2008" -std= diagnostic for PURE + VALUE X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 82407 Message-Id: <4D51BF97.8080608@net-b.de> To: gfortran , gcc patches Date: Tue, 08 Feb 2011 23:11:35 +0100 From: Tobias Burnus List-Id: 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: 2011-02-01 Tobias Burnus PR fortran/47550 * resolve.c (resolve_formal_arglist): PURE with VALUE and no INTENT: Add -std= diagnostics. 2011-02-01 Tobias Burnus 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