From 102defd50f4f43e98a601111dbdb913334329d5b Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Thu, 23 Apr 2020 10:33:14 +0100 Subject: Fortran : Spurious warning message with -Wsurprising PR59107 This change is from a patch developed for gcc-5. The code has moved on since then requiring a change to interface.c 2020-05-11 Janus Weil Dominique d'Humieres gcc/fortran/ PR fortran/59107 * gfortran.h: Rename field resolved as resolve_symbol_called and assign two 2 bits instead of 1. * interface.c (check_dtio_interface1): Use new field name. (gfc_find_typebound_dtio_proc): Use new field name. * resolve.c (gfc_resolve_intrinsic): Replace check of the formal field with resolve_symbol_called is at least 2, if it is not set the field to 2. (resolve_typebound_procedure): Use new field name. (resolve_symbol): Use new field name and check whether it is at least 1, if it is not set the field to 1. 2020-05-11 Mark Eggleston gcc/testsuite/ PR fortran/59107 * gfortran.dg/pr59107.f90: New test. --- gcc/fortran/interface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/fortran/interface.c') diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index ba1c8bc..f33c663 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -5015,7 +5015,7 @@ check_dtio_interface1 (gfc_symbol *derived, gfc_symtree *tb_io_st, gfc_error ("DTIO procedure %qs at %L must be a subroutine", dtio_sub->name, &dtio_sub->declared_at); - if (!dtio_sub->resolved) + if (!dtio_sub->resolve_symbol_called) gfc_resolve_formal_arglist (dtio_sub); arg_num = 0; @@ -5149,7 +5149,8 @@ gfc_find_typebound_dtio_proc (gfc_symbol *derived, bool write, bool formatted) gfc_symtree *tb_io_st = NULL; bool t = false; - if (!derived || !derived->resolved || derived->attr.flavor != FL_DERIVED) + if (!derived || !derived->resolve_symbol_called + || derived->attr.flavor != FL_DERIVED) return NULL; /* Try to find a typebound DTIO binding. */ -- cgit v1.1 From 45a7cfbffa39e02571b934cbc762d093a63e0581 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 20 Jun 2020 16:09:45 +0200 Subject: PR fortran/95689 - ICE in check_sym_interfaces, at fortran/interface.c:2015 With submodules, name mangling of interfaces may result in long internal symbols overflowing an internal buffer. We now check that we do not exceed the enlarged buffer size. gcc/fortran/ PR fortran/95689 * interface.c (check_sym_interfaces): Enlarge temporary buffer, and add check on length on mangled name to prevent overflow. --- gcc/fortran/interface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/interface.c') diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f33c663..b1a75a3 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1981,7 +1981,8 @@ check_interface1 (gfc_interface *p, gfc_interface *q0, static void check_sym_interfaces (gfc_symbol *sym) { - char interface_name[GFC_MAX_SYMBOL_LEN + sizeof("generic interface ''")]; + /* Provide sufficient space to hold "generic interface 'symbol.symbol'". */ + char interface_name[2*GFC_MAX_SYMBOL_LEN+2 + sizeof("generic interface ''")]; gfc_interface *p; if (sym->ns != gfc_current_ns) @@ -1989,6 +1990,8 @@ check_sym_interfaces (gfc_symbol *sym) if (sym->generic != NULL) { + size_t len = strlen (sym->name) + sizeof("generic interface ''"); + gcc_assert (len < sizeof (interface_name)); sprintf (interface_name, "generic interface '%s'", sym->name); if (check_interface0 (sym->generic, interface_name)) return; -- cgit v1.1 From fb4a20d95983d4c6548cf559ab3021f67671b5e4 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Thu, 25 Jun 2020 05:16:50 +0100 Subject: Fortran : ICE in generic_correspondence PR95584 Output an error for ambiguous interfaces in generic interface instead of ICE. 2020-07-02 Steven G. Kargl gcc/fortran/ PR fortran/95584 * interface.c (generic_correspondence): Only use the pointer to a symbol if exists. 2020-07-02 Mark Eggleston gcc/testsuite/ PR fortran/95584 * gfortran.dg/pr95584.f90: New test. --- gcc/fortran/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/fortran/interface.c') diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index b1a75a3..0cc504f 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1257,7 +1257,7 @@ generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2, while (f1) { - if (f1->sym->attr.optional) + if (!f1->sym || f1->sym->attr.optional) goto next; if (p1 && strcmp (f1->sym->name, p1) == 0) -- cgit v1.1 From 6514093826003512254c3d575fde9e26bf1710e8 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 11 Jul 2020 19:16:16 +0200 Subject: Fix ICE on warning with new interface check. In the test case, there was a warning about INTENT where an EXTERNAL masked an interface in an outer scope, when the location of the symbol was not set, leading to an ICE. Two problems, two-part solution: It makes no sense to warn about INTENT for artificially generated formal argument lists, and the location should be set. gcc/fortran/ChangeLog: PR fortran/96073 * frontend-passes.c (check_externals_procedure): Add locus information for new_sym. * interface.c (gfc_check_dummy_characteristics): Do not warn about INTENT for artificially generated variables. gcc/testsuite/ChangeLog: PR fortran/96073 * gfortran.dg/interface_48.f90: New test. --- gcc/fortran/interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/interface.c') diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 0cc504f..e518209 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1343,7 +1343,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, } /* Check INTENT. */ - if (s1->attr.intent != s2->attr.intent) + if (s1->attr.intent != s2->attr.intent && !s1->attr.artificial + && !s2->attr.artificial) { snprintf (errmsg, err_len, "INTENT mismatch in argument '%s'", s1->name); -- cgit v1.1 From 41dd828f7dc88154d82b0fb9666c553823412078 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sun, 2 Aug 2020 10:57:59 +0100 Subject: This patch fixes PR96320. See the explanatory comment in the testcase. 2020-08-01 Paul Thomas gcc/fortran PR target/96320 * interface.c (gfc_check_dummy_characteristics): If a module procedure arrives with assumed shape in the interface and deferred shape in the procedure itself, update the latter and copy the lower bounds. gcc/testsuite/ PR target/96320 * gfortran.dg/module_procedure_4.f90 : New test. --- gcc/fortran/interface.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'gcc/fortran/interface.c') diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index e518209..7985fc7 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1466,6 +1466,19 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, int i, compval; gfc_expr *shape1, *shape2; + /* Sometimes the ambiguity between deferred shape and assumed shape + does not get resolved in module procedures, where the only explicit + declaration of the dummy is in the interface. */ + if (s1->ns->proc_name && s1->ns->proc_name->attr.module_procedure + && s1->as->type == AS_ASSUMED_SHAPE + && s2->as->type == AS_DEFERRED) + { + s2->as->type = AS_ASSUMED_SHAPE; + for (i = 0; i < s2->as->rank; i++) + if (s1->as->lower[i] != NULL) + s2->as->lower[i] = gfc_copy_expr (s1->as->lower[i]); + } + if (s1->as->type != s2->as->type) { snprintf (errmsg, err_len, "Shape mismatch in argument '%s'", @@ -2617,7 +2630,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, || (actual->rank == 0 && formal->attr.dimension && gfc_is_coindexed (actual))) { - if (where + if (where && (!formal->attr.artificial || (!formal->maybe_array && !maybe_dummy_array_arg (actual)))) { @@ -2708,7 +2721,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, if (ref == NULL && actual->expr_type != EXPR_NULL) { - if (where + if (where && (!formal->attr.artificial || (!formal->maybe_array && !maybe_dummy_array_arg (actual)))) { @@ -3965,7 +3978,7 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where) if (!gfc_compare_actual_formal (ap, dummy_args, 0, sym->attr.elemental, sym->attr.proc == PROC_ST_FUNCTION, where)) return false; - + if (!check_intents (dummy_args, *ap)) return false; -- cgit v1.1