diff options
author | Tobias Burnus <burnus@net-b.de> | 2011-02-11 22:07:17 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2011-02-11 22:07:17 +0100 |
commit | a26e8df4dcf99181598e35b599663c6f484dec72 (patch) | |
tree | 56b66b81ad62bc528a894a33f1d79ba5c4b08e46 /gcc | |
parent | 3f82421f9c460408f21dc8a68079957aada10c0e (diff) | |
download | gcc-a26e8df4dcf99181598e35b599663c6f484dec72.zip gcc-a26e8df4dcf99181598e35b599663c6f484dec72.tar.gz gcc-a26e8df4dcf99181598e35b599663c6f484dec72.tar.bz2 |
re PR fortran/47550 (PURE with VALUE and w/o INTENT: add gfc_notify_std (GFC_STD_F2008 ?)
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-11 Tobias Burnus <burnus@net-b.de>
PR fortran/47550
* gfortran.dg/pure_formal_2.f90: New.
From-SVN: r170060
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pure_formal_2.f90 | 18 |
4 files changed, 51 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 80cc4da..9980d4d 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 0fe0672..fefb643 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 d680a16..996c2d9 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 0000000..b3c8a0e --- /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 |