diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-01-25 17:55:25 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-01-25 17:55:25 +0000 |
commit | f28c46cdb85172eb0e267b97e7a9d3befac30a2e (patch) | |
tree | 2242dbbebcc8ad8d6a1410458a54359107bf39f0 /gcc | |
parent | 1009e9a2e43a42546cb0bc98fa56199663895b88 (diff) | |
download | gcc-f28c46cdb85172eb0e267b97e7a9d3befac30a2e.zip gcc-f28c46cdb85172eb0e267b97e7a9d3befac30a2e.tar.gz gcc-f28c46cdb85172eb0e267b97e7a9d3befac30a2e.tar.bz2 |
re PR fortran/85780 (ICE in resolve_fl_procedure, at fortran/resolve.c:12504)
2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85780
* decl.c (gfc_match_subroutine): Check for conflict between BIND(C)
and alternative return.
2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/85780
* gfortran.dg/pr85780.f90: Update testcase for error message.
From-SVN: r268277
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr85780.f90 | 5 |
4 files changed, 30 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d728c27..5ee82a6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85780 + * decl.c (gfc_match_subroutine): Check for conflict between BIND(C) + and alternative return. + 2019-01-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/88929 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 3314e17..e798381 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7558,6 +7558,7 @@ gfc_match_subroutine (void) match is_bind_c; char peek_char; bool allow_binding_name; + locus loc; if (gfc_current_state () != COMP_NONE && gfc_current_state () != COMP_INTERFACE @@ -7623,6 +7624,8 @@ gfc_match_subroutine (void) /* Here, we are just checking if it has the bind(c) attribute, and if so, then we need to make sure it's all correct. If it doesn't, we still need to continue matching the rest of the subroutine line. */ + gfc_gobble_whitespace (); + loc = gfc_current_locus; is_bind_c = gfc_match_bind_c (sym, allow_binding_name); if (is_bind_c == MATCH_ERROR) { @@ -7634,6 +7637,8 @@ gfc_match_subroutine (void) if (is_bind_c == MATCH_YES) { + gfc_formal_arglist *arg; + /* The following is allowed in the Fortran 2008 draft. */ if (gfc_current_state () == COMP_CONTAINS && sym->ns->proc_name->attr.flavor != FL_MODULE @@ -7647,8 +7652,17 @@ gfc_match_subroutine (void) gfc_error ("Missing required parentheses before BIND(C) at %C"); return MATCH_ERROR; } - if (!gfc_add_is_bind_c (&(sym->attr), sym->name, - &(sym->declared_at), 1)) + + /* Scan the dummy arguments for an alternate return. */ + for (arg = sym->formal; arg; arg = arg->next) + if (!arg->sym) + { + gfc_error ("Alternate return dummy argument cannot appear in a " + "SUBROUTINE with the BIND(C) attribute at %L", &loc); + return MATCH_ERROR; + } + + if (!gfc_add_is_bind_c (&(sym->attr), sym->name, &(sym->declared_at), 1)) return MATCH_ERROR; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cdb816e..75ce51a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-25 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85780 + * gfortran.dg/pr85780.f90: Update testcase for error message. + 2019-01-25 Richard Earnshaw <rearnsha@arm.com> PR target/88469 diff --git a/gcc/testsuite/gfortran.dg/pr85780.f90 b/gcc/testsuite/gfortran.dg/pr85780.f90 index ad6b27f..b9432e8 100644 --- a/gcc/testsuite/gfortran.dg/pr85780.f90 +++ b/gcc/testsuite/gfortran.dg/pr85780.f90 @@ -1,5 +1,6 @@ ! { dg-do compile } -! { dg-options "-std=legacy" } +! { dg-options "-fmax-errors=1" } ! PR fortran/85780 -subroutine s(*) bind(c) +subroutine s(*) bind(c) ! { dg-error "Alternate return dummy argument" } end +! { dg-prune-output "compilation terminated" } |