From: Paul Thomas Date: Mon, 30 Nov 2015 13:33:27 +0000 (+0000) Subject: re PR fortran/68534 (No error on mismatch in number of arguments between submodule... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ef5fbc1f4b4e34e4b084f5b59b0885bfa3300fb;p=gcc.git re PR fortran/68534 (No error on mismatch in number of arguments between submodule and module interface) 2015-11-30 Paul Thomas PR fortran/68534 * decl.c (gfc_match_formal_arglist): Cope with zero formal args either in interface declaration or in procedure declaration in submodule. 2015-11-30 Paul Thomas PR fortran/68534 * gfortran.dg/submodule_13.f08: New test. From-SVN: r231072 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f1ad5e1f2b5..c7c50647d00 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-11-30 Paul Thomas + + PR fortran/68534 + * decl.c (gfc_match_formal_arglist): Cope with zero formal args + either in interface declaration or in procedure declaration in + submodule. + 2015-11-25 Steven G. Kargl PR fortran/68227 @@ -68,7 +75,7 @@ * resolve.c (gfc_resolve_blocks): Handle EXEC_OACC_DECLARE. * st.c (gfc_free_statement): Handle EXEC_OACC_DECLARE. * symbol.c (check_conflict): Add conflict checks. - (gfc_add_oacc_declare_create, gfc_add_oacc_declare_copyin, + (gfc_add_oacc_declare_create, gfc_add_oacc_declare_copyin, gfc_add_oacc_declare_deviceptr, gfc_add_oacc_declare_device_resident): New functions. (gfc_copy_attr): Handle new symbols. @@ -84,7 +91,7 @@ 2015-11-21 Steven G. Kargl * simplify.c (gfc_simplify_cshift): Work around bootstrap issues - due to inappropriate warning options. + due to inappropriate warning options. 2015-11-21 Steven G. Kargl @@ -93,7 +100,7 @@ (gfc_simplify_spread): Remove a FIXME and add error condition. * intrinsic.h: Prototype for gfc_simplify_cshift * intrinsic.c (add_functions): Use gfc_simplify_cshift. - + 2015-11-20 Steven G. Kargl PR fortran/68237 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index c4ce18b9ad9..10a08e0591b 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4817,14 +4817,23 @@ ok: goto cleanup; } - if (formal) + if (progname->attr.module_procedure && progname->attr.host_assoc) { + bool arg_count_mismatch = false; + + if (!formal && head) + arg_count_mismatch = true; + + /* Abbreviated module procedure declaration is not meant to have any + formal arguments! */ + if (!sym->abr_modproc_decl && formal && !head) + arg_count_mismatch = true; + for (p = formal, q = head; p && q; p = p->next, q = q->next) { if ((p->next != NULL && q->next == NULL) || (p->next == NULL && q->next != NULL)) - gfc_error_now ("Mismatch in number of MODULE PROCEDURE " - "formal arguments at %C"); + arg_count_mismatch = true; else if ((p->sym == NULL && q->sym == NULL) || strcmp (p->sym->name, q->sym->name) == 0) continue; @@ -4833,6 +4842,10 @@ ok: "argument names (%s/%s) at %C", p->sym->name, q->sym->name); } + + if (arg_count_mismatch) + gfc_error_now ("Mismatch in number of MODULE PROCEDURE " + "formal arguments at %C"); } return MATCH_YES; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 546bc2e355e..805d7943d25 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-30 Paul Thomas + + PR fortran/68534 + * gfortran.dg/submodule_13.f08: New test. + 2015-11-30 Andreas Krebbel * gcc.target/s390/load-relative-check.c: Add scan patterns for diff --git a/gcc/testsuite/gfortran.dg/submodule_13.f08 b/gcc/testsuite/gfortran.dg/submodule_13.f08 new file mode 100644 index 00000000000..6a4d2ad113e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/submodule_13.f08 @@ -0,0 +1,32 @@ +! { dg-do compile } +! +! Checks the fix for PR68534 in which checks for the number +! failed if either the interface or the module procedure had +! no dummies. +! +! Reported on clf at: +! https://groups.google.com/forum/#!topic/comp.lang.fortran/-ZgbM5qkFmc +! +module m + implicit none + interface + module subroutine foo() + end subroutine foo + + module subroutine bar(i) + integer, intent(inout) :: i + end subroutine bar + end interface +end module m + +submodule(m) sm +contains + module subroutine foo(i) ! { dg-error "Mismatch in number of MODULE PROCEDURE formal" } + integer, intent(inout) :: i + i = 42 + end subroutine foo + + module subroutine bar ! { dg-error "Mismatch in number of MODULE PROCEDURE formal" } + print *, "bar" + end subroutine bar +end submodule sm