From 264201216816c9145e40b856628a6c3e3eec6178 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sun, 13 Jan 2019 04:02:46 +0000 Subject: [PATCH] re PR fortran/61765 ([F03] Rejects valid BIND(C) ENTRY) 2019-01-12 Steven G. Kargl PR fortran/61765 * resolve.c (gfc_verify_binding_labels): Break if-elseif-elseif structure into independent if's with a return to simplify logic. Avoid a check for ENTRY name with bind(c). 2019-01-12 Steven G. Kargl PR fortran/61765 * gfortran.dg/pr61765.f90: New test. From-SVN: r267902 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/resolve.c | 25 ++++++++++++++----------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr61765.f90 | 15 +++++++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr61765.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a34fbd8a1fb..50db133fa39 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-01-12 Steven G. Kargl + + PR fortran/61765 + * resolve.c (gfc_verify_binding_labels): Break if-elseif-elseif + structure into independent if's with a return to simplify logic. + Avoid a check for ENTRY name with bind(c). + 2019-01-12 Paul Thomas * gfortran.texi : Add description in sections on TS 29113 and diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index d18f2d8aefa..155e7c921cf 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11789,11 +11789,12 @@ gfc_verify_binding_labels (gfc_symbol *sym) sym->binding_label, &sym->declared_at, &gsym->where); /* Clear the binding label to prevent checking multiple times. */ sym->binding_label = NULL; - + return; } - else if (sym->attr.flavor == FL_VARIABLE && module - && (strcmp (module, gsym->mod_name) != 0 - || strcmp (sym->name, gsym->sym_name) != 0)) + + if (sym->attr.flavor == FL_VARIABLE && module + && (strcmp (module, gsym->mod_name) != 0 + || strcmp (sym->name, gsym->sym_name) != 0)) { /* This can only happen if the variable is defined in a module - if it isn't the same module, reject it. */ @@ -11802,14 +11803,16 @@ gfc_verify_binding_labels (gfc_symbol *sym) sym->name, module, sym->binding_label, &sym->declared_at, &gsym->where, gsym->mod_name); sym->binding_label = NULL; + return; } - else if ((sym->attr.function || sym->attr.subroutine) - && ((gsym->type != GSYM_SUBROUTINE && gsym->type != GSYM_FUNCTION) - || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY)) - && sym != gsym->ns->proc_name - && (module != gsym->mod_name - || strcmp (gsym->sym_name, sym->name) != 0 - || (module && strcmp (module, gsym->mod_name) != 0))) + + if ((sym->attr.function || sym->attr.subroutine) + && ((gsym->type != GSYM_SUBROUTINE && gsym->type != GSYM_FUNCTION) + || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY)) + && (sym != gsym->ns->proc_name && sym->attr.entry == 0) + && (module != gsym->mod_name + || strcmp (gsym->sym_name, sym->name) != 0 + || (module && strcmp (module, gsym->mod_name) != 0))) { /* Print an error if the procedure is defined multiple times; we have to exclude references to the same procedure via module association or diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f781aed62e..0398fb82874 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-12 Steven G. Kargl + + PR fortran/61765 + * gfortran.dg/pr61765.f90: New test. + 2019-01-12 Paolo Carlini * g++.dg/cpp0x/pr62101.C: Test locations too. diff --git a/gcc/testsuite/gfortran.dg/pr61765.f90 b/gcc/testsuite/gfortran.dg/pr61765.f90 new file mode 100644 index 00000000000..080d1ac389b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr61765.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } + subroutine sub1(x) + integer, intent(in) :: x + entry sub1_c(x) bind(c) + end subroutine sub1 + + subroutine sub2_c(x) bind(c) + integer, intent(in) :: x + entry sub2(x) + end subroutine sub2_c + + subroutine sub3_c(x) bind(c) + integer, intent(in) :: x + entry sub3_c_c(x) bind(c) + end subroutine sub3_c -- 2.30.2