diff options
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/stmt_func_1.f90 | 12 |
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 888432e..ecdf2de 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,12 @@ 2011-01-31 Tobias Burnus <burnus@net-b.de> PR fortran/47042 + * resolve.c (resolve_fl_procedure): Reject stmt functions + with pointer/allocatable attribute. + +2011-01-31 Tobias Burnus <burnus@net-b.de> + + PR fortran/47042 * interface.c (gfc_procedure_use): Add explicit interface check for pointer/allocatable functions. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 55b5183..20be0d1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -10231,6 +10231,14 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) return FAILURE; } + if (sym->attr.proc == PROC_ST_FUNCTION + && (sym->attr.allocatable || sym->attr.pointer)) + { + gfc_error ("Statement function '%s' at %L may not have pointer or " + "allocatable attribute", sym->name, &sym->declared_at); + return FAILURE; + } + /* 5.1.1.5 of the Standard: A function name declared with an asterisk char-len-param shall not be array-valued, pointer-valued, recursive or pure. ....snip... A character value of * may only be used in the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d432ef..c8de82a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2011-01-31 Tobias Burnus <burnus@net-b.de> PR fortran/47042 + * gfortran.dg/stmt_func_1.f90: New. + +2011-01-31 Tobias Burnus <burnus@net-b.de> + + PR fortran/47042 * gfortran.dg/interface_34.f90: New. 2011-01-30 Paul Thomas <pault@gcc.gnu.org> diff --git a/gcc/testsuite/gfortran.dg/stmt_func_1.f90 b/gcc/testsuite/gfortran.dg/stmt_func_1.f90 new file mode 100644 index 0000000..072f21b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/stmt_func_1.f90 @@ -0,0 +1,12 @@ +! { dg-compile } +! { dg-options "" } +! +! PR fortran/47542 +! +integer, target, save :: tgt = 77 +integer, pointer ::ptr_stmt ! { dg-error "Statement function .ptr_stmt. at .1. may not have pointer or allocatable attribute" } +integer, allocatable :: alloc_stmt ! { dg-error "Statement function .alloc_stmt. at .1. may not have pointer or allocatable attribute" } + +ptr_stmt() = tgt +alloc_stmt() = 78 +end |