This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PRs fortran/82972, fortran/83088, fortran/85851] Fix ICE with -finit-derived when using iso_c_binding
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Fritz Reese <fritzoreese at gmail dot com>
- Cc: fortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 23 Jun 2018 08:57:38 -0700
- Subject: Re: [PRs fortran/82972, fortran/83088, fortran/85851] Fix ICE with -finit-derived when using iso_c_binding
- References: <CAE4aFAnojLRxF0D_Dvp8LmCu5z0hzm_E4Y6CkWqHgqOenzXPHA@mail.gmail.com>
- Reply-to: sgk at troutmask dot apl dot washington dot edu
On Fri, Jun 22, 2018 at 04:46:19PM -0400, Fritz Reese wrote:
>
> In any case, the changelog is here, and the patch is attached. Aside
> from the issues mentioned below the compile bootstraps and regression
> tests successfully. Does this look OK for trunk? Furthermore, this
> patch comes a bit late as the PRs were submitted before 8.1 was
> released; is it appropriate to backport this to 7-branch and/or
> 8-branch?
OK with minor style fixes (see below). Note, I cannot reproduce
the issues that you saw. Please keep an eye on the list for a
regression.
> +/* Generate an initializer expression for an iso_c_binding type
> + such as c_[fun]ptr. The appropriate initializer is c_null_[fun]ptr. */
> +
> +static gfc_expr *
> +generate_isocbinding_initializer (gfc_symbol *derived)
> +{
> + /* The initializers have already been built into the c_null_[fun]ptr symbols
> + from gen_special_c_interop_ptr. */
> +
> + gfc_symtree *npsym = NULL;
> + if (0 == strcmp(derived->name, "c_ptr"))
Missing space. strcmp ()
> + gfc_find_sym_tree("c_null_ptr", gfc_current_ns, true, &npsym);
same here
> + else if (0 == strcmp(derived->name, "c_funptr"))
same here
> + gfc_find_sym_tree("c_null_funptr", gfc_current_ns, true, &npsym);
same here
> + else
> + gfc_internal_error ("generate_isocbinding_initializer(): bad iso_c_binding"
> + " type, expected %<c_ptr%> or %<c_funptr%>");
> + if (npsym)
> + {
> + gfc_expr *init = gfc_copy_expr(npsym->n.sym->value);
same here
> + init->symtree = npsym;
> + init->ts.is_iso_c = true;
> + return init;
> + }
> +
> + return NULL;
> +}
>
> /* Get or generate an expression for a default initializer of a derived type.
> If -finit-derived is specified, generate default initialization expressions
> @@ -4498,8 +4525,12 @@ gfc_generate_initializer (gfc_typespec *ts, bool generate)
> {
> gfc_expr *init, *tmp;
> gfc_component *comp;
> +
> generate = flag_init_derived && generate;
>
> + if (ts->u.derived->ts.is_iso_c && generate)
> + return generate_isocbinding_initializer(ts->u.derived);
same here
--
Steve