From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2331 invoked by alias); 8 Jan 2019 08:49:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 129418 invoked by uid 89); 8 Jan 2019 08:49:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,HTML_MESSAGE,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:alternative X-HELO: mail-yw1-f68.google.com Received: from mail-yw1-f68.google.com (HELO mail-yw1-f68.google.com) (209.85.161.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 08:49:20 +0000 Received: by mail-yw1-f68.google.com with SMTP id f65so1238276ywc.8; Tue, 08 Jan 2019 00:49:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Janne Blomqvist Date: Tue, 08 Jan 2019 08:49:00 -0000 Message-ID: Subject: Re: [PATCH] Fix PR88611 To: Richard Biener Cc: GCC Patches , Fortran List Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2019-01/txt/msg00370.txt.bz2 On Tue, Jan 8, 2019 at 10:18 AM Richard Biener wrote: > > This is about the Fortran FE creating global variable initializers > with wrong type (integer type rather than pointer type) for > ISOCBINDING_NULL_* initializers. The patch simplifies the logic > in gfc_conv_initializer to directly create the expected GENERIC > rather than trying to use the scalarizer. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, ok? > > Thanks, > Richard. > > 2019-01-08 Richard Biener > > PR fortran/88611 > * trans-expr.c (gfc_conv_initializer): For ISOCBINDING_NULL_* > directly build the expected GENERIC tree. > > * gfortran.dg/pr88611.f90: New testcase. > > Index: gcc/fortran/trans-expr.c > =================================================================== > --- gcc/fortran/trans-expr.c (revision 267671) > +++ gcc/fortran/trans-expr.c (working copy) > @@ -7086,19 +7086,12 @@ gfc_conv_initializer (gfc_expr * expr, g > if (expr != NULL && expr->ts.type == BT_DERIVED > && expr->ts.is_iso_c && expr->ts.u.derived) > { > - gfc_symbol *derived = expr->ts.u.derived; > - > - /* The derived symbol has already been converted to a (void *). Use > - its kind. */ > - if (derived->ts.kind == 0) > - derived->ts.kind = gfc_default_integer_kind; > - expr = gfc_get_int_expr (derived->ts.kind, NULL, 0); > - expr->ts.f90_type = derived->ts.f90_type; > - > - gfc_init_se (&se, NULL); > - gfc_conv_constant (&se, expr); > - gcc_assert (TREE_CODE (se.expr) != CONSTRUCTOR); > - return se.expr; > + if (TREE_CODE (type) == ARRAY_TYPE) > + return build_constructor (type, NULL); > + else if (POINTER_TYPE_P (type)) > + return build_int_cst (type, 0); > + else > + gcc_unreachable (); > } > > if (array && !procptr) > Index: gcc/testsuite/gfortran.dg/pr88611.f90 > =================================================================== > --- gcc/testsuite/gfortran.dg/pr88611.f90 (nonexistent) > +++ gcc/testsuite/gfortran.dg/pr88611.f90 (working copy) > @@ -0,0 +1,14 @@ > +! { dg-do run } > +! { dg-options "-fdefault-integer-8 -fno-tree-forwprop -O3 -fno-tree-ccp" > } > +! PR 82869 > +! A temp variable of type logical was incorrectly transferred > +! to the I/O library as a logical type of a different kind. > +program pr82869_8 > + use, intrinsic :: iso_c_binding > + type(c_ptr) :: p = c_null_ptr > + character(len=4) :: s > + write (s, *) c_associated(p), c_associated(c_null_ptr) > + if (s /= ' F F') then > + STOP 1 > + end if > +end program pr82869_8 > Ok, thanks. -- Janne Blomqvist