This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran patches
On Thu, Dec 06, 2018 at 05:21:32PM -0800, Steve Kargl wrote:
>
> Here's an alternative patch that would reject a subroutine
> with an alternate return dummy argument with the bind(c)
> attributes. I'm still trying to determine if the code
> should be legal. The c.l.f thread I started isn't helping :(
I think I have found the restriction. In F2018,
C1554 If proc-language-binding-spec is specified for a procedure, each
of its dummy arguments shall be an interoperable procedure (18.3.7)
or a variable that is interoperable (18.3.5, 18.3.6), assumed-shape,
assumed-rank, assumed-type, of type CHARACTER with assumed length,
or that has the ALLOCATABLE or POINTER attribute.
>
> Index: decl.c
> ===================================================================
> --- decl.c (revision 266766)
> +++ decl.c (working copy)
> @@ -7467,6 +7467,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
> @@ -7532,6 +7533,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)
> {
> @@ -7543,6 +7546,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
> @@ -7556,8 +7561,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;
> }
>
> --
> steve
--
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow