From 6de7294fd4a37431a5c9df578feca6fece431077 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Thu, 14 May 2009 11:41:41 +0200 Subject: re PR fortran/39996 (Double typing of function results not detected) 2009-05-14 Janus Weil PR fortran/39996 * decl.c (gfc_match_function_decl): Use gfc_add_type. * symbol.c (gfc_add_type): Better checking for duplicate types in function declarations. And: Always give an error for duplicte types, not just a warning with -std=gnu. 2009-05-14 Janus Weil PR fortran/39996 * gfortran.dg/func_decl_2.f90: Modified (replacing warnings by errors). * gfortran.dg/duplicate_type_2.f90: Ditto. * gfortran.dg/duplicate_type_3.f90: New. From-SVN: r147528 --- gcc/fortran/decl.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'gcc/fortran/decl.c') diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 7aa550e..6c6fa45 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4708,14 +4708,6 @@ gfc_match_function_decl (void) || copy_prefix (&sym->attr, &sym->declared_at) == FAILURE) goto cleanup; - if (current_ts.type != BT_UNKNOWN && sym->ts.type != BT_UNKNOWN - && !sym->attr.implicit_type) - { - gfc_error ("Function '%s' at %C already has a type of %s", name, - gfc_basic_typename (sym->ts.type)); - goto cleanup; - } - /* Delay matching the function characteristics until after the specification block by signalling kind=-1. */ sym->declared_at = old_loc; @@ -4726,12 +4718,17 @@ gfc_match_function_decl (void) if (result == NULL) { - sym->ts = current_ts; + if (current_ts.type != BT_UNKNOWN + && gfc_add_type (sym, ¤t_ts, &gfc_current_locus) == FAILURE) + goto cleanup; sym->result = sym; } else { - result->ts = current_ts; + if (current_ts.type != BT_UNKNOWN + && gfc_add_type (result, ¤t_ts, &gfc_current_locus) + == FAILURE) + goto cleanup; sym->result = result; } -- cgit v1.1