From b4439561c4019cf3bc4c59cc6260d7464917f1e5 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 12 Oct 2018 20:13:25 +0200 Subject: Fix error-recovery ICE in check_proc_interface PR fortran/58787 * decl.c (get_proc_name): Return with error before creating sym_tree. PR fortran/58787 * gfortran.dg/goacc/pr77765.f90: Modify dg-error. * gfortran.dg/interface_42.f90: Ditto. * gfortran.dg/internal_references_1.f90: Ditto. * gfortran.dg/invalid_procedure_name.f90: Ditto. * gfortran.dg/pr65453.f90: Ditto. * gfortran.dg/pr77414.f90: Ditto. * gfortran.dg/pr78741.f90: Ditto. * gfortran.dg/same_name_2.f90: Ditto. From-SVN: r265125 --- gcc/fortran/decl.c | 54 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'gcc/fortran/decl.c') diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 7f79811..87c736f 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1231,28 +1231,39 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) && sym->attr.proc != 0 && (sym->attr.subroutine || sym->attr.function || sym->attr.entry) && sym->attr.if_source != IFSRC_UNKNOWN) - gfc_error_now ("Procedure %qs at %C is already defined at %L", - name, &sym->declared_at); - + { + gfc_error_now ("Procedure %qs at %C is already defined at %L", + name, &sym->declared_at); + return true; + } if (sym->attr.flavor != 0 && sym->attr.entry && sym->attr.if_source != IFSRC_UNKNOWN) - gfc_error_now ("Procedure %qs at %C is already defined at %L", - name, &sym->declared_at); + { + gfc_error_now ("Procedure %qs at %C is already defined at %L", + name, &sym->declared_at); + return true; + } if (sym->attr.external && sym->attr.procedure && gfc_current_state () == COMP_CONTAINS) - gfc_error_now ("Contained procedure %qs at %C clashes with " - "procedure defined at %L", - name, &sym->declared_at); + { + gfc_error_now ("Contained procedure %qs at %C clashes with " + "procedure defined at %L", + name, &sym->declared_at); + return true; + } /* Trap a procedure with a name the same as interface in the encompassing scope. */ if (sym->attr.generic != 0 && (sym->attr.subroutine || sym->attr.function) && !sym->attr.mod_proc) - gfc_error_now ("Name %qs at %C is already defined" - " as a generic interface at %L", - name, &sym->declared_at); + { + gfc_error_now ("Name %qs at %C is already defined" + " as a generic interface at %L", + name, &sym->declared_at); + return true; + } /* Trap declarations of attributes in encompassing scope. The signature for this is that ts.kind is set. Legitimate @@ -1263,8 +1274,11 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) && gfc_current_ns->parent != NULL && sym->attr.access == 0 && !module_fcn_entry) - gfc_error_now ("Procedure %qs at %C has an explicit interface " + { + gfc_error_now ("Procedure %qs at %C has an explicit interface " "from a previous declaration", name); + return true; + } } /* C1246 (R1225) MODULE shall appear only in the function-stmt or @@ -1276,17 +1290,23 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) && !current_attr.module_procedure && sym->attr.proc == PROC_MODULE && gfc_state_stack->state == COMP_CONTAINS) - gfc_error_now ("Procedure %qs defined in interface body at %L " - "clashes with internal procedure defined at %C", - name, &sym->declared_at); + { + gfc_error_now ("Procedure %qs defined in interface body at %L " + "clashes with internal procedure defined at %C", + name, &sym->declared_at); + return true; + } if (sym && !sym->gfc_new && sym->attr.flavor != FL_UNKNOWN && sym->attr.referenced == 0 && sym->attr.subroutine == 1 && gfc_state_stack->state == COMP_CONTAINS && gfc_state_stack->previous->state == COMP_SUBROUTINE) - gfc_error_now ("Procedure %qs at %C is already defined at %L", - name, &sym->declared_at); + { + gfc_error_now ("Procedure %qs at %C is already defined at %L", + name, &sym->declared_at); + return true; + } if (gfc_current_ns->parent == NULL || *result == NULL) return rc; -- cgit v1.1