diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2007-04-07 20:13:52 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2007-04-07 20:13:52 +0000 |
commit | e9bd9f7d5db94db21cdd566e9e00f851563edc97 (patch) | |
tree | 4952f685177a36049f5019f89ef57303fb8f5eab /gcc/fortran | |
parent | ca178f85a63290092282309bc58d624379f749b9 (diff) | |
download | gcc-e9bd9f7d5db94db21cdd566e9e00f851563edc97.zip gcc-e9bd9f7d5db94db21cdd566e9e00f851563edc97.tar.gz gcc-e9bd9f7d5db94db21cdd566e9e00f851563edc97.tar.bz2 |
re PR fortran/31293 (Implicit character and array returning functions)
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31293
* symbol.c (gfc_check_function_type): New function.
* gfortran.h : Add prototype for previous.
* parse.c (parse_progunit): Call it after parsing specification
statements.
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31293
* gfortran.dg/interface_12.f90: New test.
From-SVN: r123641
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 4 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 3 | ||||
-rw-r--r-- | gcc/fortran/symbol.c | 31 |
4 files changed, 45 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5b3001f..e72aa0d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2007-04-07 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/31293 + * symbol.c (gfc_check_function_type): New function. + * gfortran.h : Add prototype for previous. + * parse.c (parse_progunit): Call it after parsing specification + statements. + 2007-04-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31483
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 3ef4902..e9c71cd 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -483,7 +483,8 @@ typedef struct /* Variable attributes. */ unsigned allocatable:1, dimension:1, external:1, intrinsic:1, optional:1, pointer:1, save:1, target:1, value:1, volatile_:1, - dummy:1, result:1, assign:1, threadprivate:1, not_always_present:1; + dummy:1, result:1, assign:1, threadprivate:1, not_always_present:1, + implied_index:1; unsigned data:1, /* Symbol is named in a DATA statement. */ protected:1, /* Symbol has been marked as protected. */ @@ -1853,6 +1854,7 @@ void gfc_clear_new_implicit (void); try gfc_add_new_implicit_range (int, int); try gfc_merge_new_implicit (gfc_typespec *); void gfc_set_implicit_none (void); +void gfc_check_function_type (gfc_namespace *); gfc_typespec *gfc_get_default_type (gfc_symbol *, gfc_namespace *); try gfc_set_default_type (gfc_symbol *, int, gfc_namespace *); diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 2d17167..9e47ea4 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -2915,6 +2915,9 @@ parse_progunit (gfc_statement st) break; } + if (gfc_current_state () == COMP_FUNCTION) + gfc_check_function_type (gfc_current_ns); + loop: for (;;) { diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index b1c5ea3..ad99595 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -253,6 +253,37 @@ gfc_set_default_type (gfc_symbol * sym, int error_flag, gfc_namespace * ns) } +/* This function is called from parse.c(parse_progunit) to check the + type of the function is not implicitly typed in the host namespace + and to implicitly type the function result, if necessary. */ + +void +gfc_check_function_type (gfc_namespace *ns) +{ + gfc_symbol *proc = ns->proc_name; + + if (!proc->attr.contained || proc->result->attr.implicit_type) + return; + + if (proc->result->ts.type == BT_UNKNOWN) + { + if (gfc_set_default_type (proc->result, 0, gfc_current_ns) + == SUCCESS) + { + if (proc->result != proc) + proc->ts = proc->result->ts; + } + else + { + gfc_error ("unable to implicitly type the function result " + "'%s' at %L", proc->result->name, + &proc->result->declared_at); + proc->result->attr.untyped = 1; + } + } +} + + /******************** Symbol attribute stuff *********************/ /* This is a generic conflict-checker. We do this to avoid having a |