From: Tobias Burnus Date: Fri, 11 Feb 2011 21:07:17 +0000 (+0100) Subject: re PR fortran/47550 (PURE with VALUE and w/o INTENT: add gfc_notify_std (GFC_STD_F2008 ?) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a26e8df4dcf99181598e35b599663c6f484dec72;p=gcc.git re PR fortran/47550 (PURE with VALUE and w/o INTENT: add gfc_notify_std (GFC_STD_F2008 ?) 2011-02-11 Tobias Burnus PR fortran/47550 * resolve.c (resolve_formal_arglist): PURE with VALUE and no INTENT: Add -std= diagnostics. 2011-02-11 Tobias Burnus PR fortran/47550 * gfortran.dg/pure_formal_2.f90: New. From-SVN: r170060 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 80cc4da5d80..9980d4ddd69 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-02-11 Tobias Burnus + + PR fortran/47550 + * resolve.c (resolve_formal_arglist): PURE with VALUE + and no INTENT: Add -std= diagnostics. + 2011-02-09 Janus Weil PR fortran/47352 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 0fe067290d6..fefb6436c96 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -341,17 +341,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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d680a16d309..996c2d9ded3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-11 Tobias Burnus + + PR fortran/47550 + * gfortran.dg/pure_formal_2.f90: New. + 2011-02-11 Pat Haugen PR rtl-optimization/47614 diff --git a/gcc/testsuite/gfortran.dg/pure_formal_2.f90 b/gcc/testsuite/gfortran.dg/pure_formal_2.f90 new file mode 100644 index 00000000000..b3c8a0e0e2c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pure_formal_2.f90 @@ -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