From: Janus Weil Date: Thu, 29 Sep 2011 11:57:35 +0000 (+0200) Subject: re PR fortran/50547 (dummy procedure argument of PURE shall be PURE) X-Git-Tag: releases/gcc-4.7.0~3471 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4056cc1ba5e5590529b257a12f80270d552019b9;p=thirdparty%2Fgcc.git re PR fortran/50547 (dummy procedure argument of PURE shall be PURE) 2011-09-29 Janus Weil PR fortran/50547 * resolve.c (resolve_formal_arglist): Fix pureness check for dummy functions. PR fortran/50553 * symbol.c (check_conflict): Forbid TARGET attribute for statement functions. 2011-09-29 Janus Weil PR fortran/50547 * gfortran.dg/pure_formal_proc_3.f90: New. PR fortran/50553 * gfortran.dg/stfunc_7.f90: New. From-SVN: r179345 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 99d2d3c812ad..ecd9fa3a740a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2011-09-29 Janus Weil + + PR fortran/50547 + * resolve.c (resolve_formal_arglist): Fix pureness check for dummy + functions. + + PR fortran/50553 + * symbol.c (check_conflict): Forbid TARGET attribute for statement + functions. + 2011-09-27 Jakub Jelinek * trans-types.c (gfc_type_for_size): Return wider type diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 13ecf1c2bf6a..84db3ddb019f 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -269,18 +269,21 @@ resolve_formal_arglist (gfc_symbol *proc) if (sym->attr.if_source != IFSRC_UNKNOWN) resolve_formal_arglist (sym); + /* F08:C1279. */ + if (gfc_pure (proc) + && sym->attr.flavor == FL_PROCEDURE && !gfc_pure (sym)) + { + gfc_error ("Dummy procedure '%s' of PURE procedure at %L must " + "also be PURE", sym->name, &sym->declared_at); + continue; + } + if (sym->attr.subroutine || sym->attr.external || sym->attr.intrinsic) { - if (gfc_pure (proc) && !gfc_pure (sym)) - { - gfc_error ("Dummy procedure '%s' of PURE procedure at %L must " - "also be PURE", sym->name, &sym->declared_at); - continue; - } - if (proc->attr.implicit_pure && !gfc_pure(sym)) proc->attr.implicit_pure = 0; + /* F08:C1289. */ if (gfc_elemental (proc)) { gfc_error ("Dummy procedure at %L not allowed in ELEMENTAL " @@ -382,7 +385,7 @@ resolve_formal_arglist (gfc_symbol *proc) if (gfc_elemental (proc)) { - /* F2008, C1289. */ + /* F08:C1289. */ if (sym->attr.codimension) { gfc_error ("Coarray dummy argument '%s' at %L to elemental " diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 25186c977ad9..46eccb46abab 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -684,6 +684,7 @@ check_conflict (symbol_attribute *attr, const char *name, locus *where) { case PROC_ST_FUNCTION: conf2 (dummy); + conf2 (target); break; case PROC_MODULE: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59aefbc93389..fb41e555112a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2011-09-29 Janus Weil + + PR fortran/50547 + * gfortran.dg/pure_formal_proc_3.f90: New. + + PR fortran/50553 + * gfortran.dg/stfunc_7.f90: New. + 2011-09-29 Artjoms Sinkarovs * gcc.c-torture/execute/vector-compare-1.c: New testcase. diff --git a/gcc/testsuite/gfortran.dg/pure_formal_proc_3.f90 b/gcc/testsuite/gfortran.dg/pure_formal_proc_3.f90 new file mode 100644 index 000000000000..38d4552801ad --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pure_formal_proc_3.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! +! PR 50547: dummy procedure argument of PURE shall be PURE +! +! Contributed by Vittorio Zecca + +pure function f(proc) + interface + function proc() ! { dg-error "must also be PURE" } + end + end interface +end diff --git a/gcc/testsuite/gfortran.dg/stfunc_7.f90 b/gcc/testsuite/gfortran.dg/stfunc_7.f90 new file mode 100644 index 000000000000..1e116462525a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/stfunc_7.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! +! PR 50553: statement function cannot be target (r178939) +! +! Contributed by Vittorio Zecca + +f(x)=x +target f ! { dg-error "attribute conflicts with" } +end