This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, Fortran] Fix PR 82886 - ICE with -finit-derived in gfc_conv_expr


All,

The attached patch fixes the ICE reported in PR 82886. The ICE is due
to compiling the program with -finit-derived, but without any other
-finit-* flag (apparently this is something which I never tried when I
introduced -finit-derived, somehow...) Previously, -finit-derived
would inherit the component initializer expressions from flags like
-finit-local-zero, -finit-integer=, -finit-logical=, etc... The
problem is, if one is not specified and a derived type variable
contains a component of the same type, the structure constructor
itself is generated, but the structure element for the component ends
up with a NULL expression.

The attached patch implements what I think is a natural solution from
the user's perspective. If -finit-derived is given, any -finit-* flags
which are not given will be treated as if -finit-local-zero was given,
for the purposes of the derived-type component initializers. (Of
course explicit -finit-* flags will still override this inference).

Regression tests pass on x86_64-redhat-linux. OK?

---
Fritz Reese

>From e70f3917a7b2d35f9baad2f09199c1ccc60a04d4 Mon Sep 17 00:00:00 2001
From: Fritz Reese <fritzoreese@gmail.com>
Date: Fri, 10 Nov 2017 16:10:06 -0500
Subject: [PATCH] Fix -finit-derived when given without other -finit-* flags.

        PR fortran/82886
        gcc/fortran/
        * gfortran.h (gfc_build_init_expr): New prototype.
        * invoke.texi (finit-derived): Update documentation.
        * expr.c (gfc_build_init_expr): New, from gfc_build_default_init_expr.
        (gfc_build_default_init_expr): Redirect to gfc_build_init_expr(,,false)
        (component_initializer): Force building initializers using
        gfc_build_init_expr(,,true).

        PR fortran/82886
        * gcc/testsuite/gfortran.dg/init_flag_16.f03: New testcase.

Attachment: pr82886.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]