diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 80cc4da5d80d405e782eb8c72e9f209c2d432727..9980d4ddd69824b751908423fb858eff624eab22 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-02-11 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-09 Janus Weil <janus@gcc.gnu.org> PR fortran/47352 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 0fe067290d6bcc9556366980d7d6ecd499df5fd0..fefb6436c96031ac68451aaac6bcda979e7d98e1 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 d680a16d3097d92c8411905c90fc56cbbe1b0c17..996c2d9ded38036c4e10067f7660b3d78dc6537d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-11 Tobias Burnus <burnus@net-b.de> + + PR fortran/47550 + * gfortran.dg/pure_formal_2.f90: New. + 2011-02-11 Pat Haugen <pthaugen@us.ibm.com> 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 0000000000000000000000000000000000000000..b3c8a0e0e2c20a2207af0be55fe8bf58c849035f --- /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