From patchwork Mon Jun 14 16:12:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= X-Patchwork-Id: 1491769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Rdb16MoE; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G3c1x5GVwz9sSn for ; Tue, 15 Jun 2021 02:13:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5910B3954457 for ; Mon, 14 Jun 2021 16:13:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5910B3954457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623687201; bh=gs3qnwn67D3LMo9pMrqAWu6XBeMBkCwWx7NVy2elaPk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Rdb16MoEzTKOzHJsePCpC2rI2nnbiTruZeYkEmbTm6XYVPjE4rPwn77UYLOjBvthy Wt5r93DUk+emReq4/NLWOA35SnMWGlMTGWsX/fPYxPxjVdKBscHgdT53E6Orqzpbzh fOiwXxI21dpg1ECeB2HGVO90E6bNaKZN+nGnY/Mw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id AB6873848410; Mon, 14 Jun 2021 16:12:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB6873848410 Received: by mail-wr1-x429.google.com with SMTP id q5so15178286wrm.1; Mon, 14 Jun 2021 09:12:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=gs3qnwn67D3LMo9pMrqAWu6XBeMBkCwWx7NVy2elaPk=; b=rmw27aBnmuLROCLx/PEvySM2OjVhgXgw/wdBn9F9iXScIeygYGG50HcBtp5psfQURi tFQ2V4MYr5l+1eObEqODMO9ghDiYMsE4/1Oex963cCF6utu8mklgXwKKaysywiAxhTbX imF6u2DM81AInk0H6COm+ou+PvAL14drFNEbDErWk4SwooT7PXkKW3k8en3oZhotP1xt cMsYrOYrMkz4+WfuDLug/DG0b4GUNnm1mZsCX8NDOCn3zXdr7/272gUCFa70qN5vEbJH pFTVZMT9cjHZM1IuZ1s6CMbTNsxdPCoJDGEpkmlkFEUpb4Fe3top0AvvC2Yj3a7s5wBr yOOg== X-Gm-Message-State: AOAM53271o4FQeywWYmbDb/S4XV/yeXKks9XV1jDLNlSLcA7Cw9Hry6B fL3ahvmjFkK6fOfgd74WQ/TGhduU4Wg= X-Google-Smtp-Source: ABdhPJx9B0T2L41ZOVdCNvK3RD9E6Hf8cSfLZznhYDP9q/EA4Z9YHdIMDuMhsZn5/8q55Kom3bwISQ== X-Received: by 2002:adf:f207:: with SMTP id p7mr19076523wro.275.1623687156458; Mon, 14 Jun 2021 09:12:36 -0700 (PDT) Received: from ?IPv6:2001:8a0:7d79:6000:ee57:8710:ea76:b2e1? ([2001:8a0:7d79:6000:ee57:8710:ea76:b2e1]) by smtp.googlemail.com with ESMTPSA id b188sm25640407wmh.18.2021.06.14.09.12.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 09:12:35 -0700 (PDT) To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Patch, fortran V2] PR fortran/100683 - Array initialization refuses valid Message-ID: Date: Mon, 14 Jun 2021 16:12:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa_via_Gcc-patches?= From: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= Reply-To: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi all! Update to a proposed patch to: PR100683 - Array initialization refuses valid due to errors found by Dominique d'Humieres. Patch tested only on x86_64-pc-linux-gnu. Add call to simplify expression before parsing *and* check if the expression is still an array after simplification. Thank you very much. Best regards, José Rui Fortran: Fix bogus error gcc/fortran/ChangeLog: PR fortran/100683 * resolve.c (gfc_resolve_expr): Add call to gfc_simplify_expr. gcc/testsuite/ChangeLog: PR fortran/100683 * gfortran.dg/PR100683.f90: New test. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a37ad66..a9518e7 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -7138,8 +7138,10 @@ gfc_resolve_expr (gfc_expr *e) /* Also try to expand a constructor. */ if (t) { + gfc_simplify_expr(e, 1); gfc_expression_rank (e); - if (gfc_is_constant_expr (e) || gfc_is_expandable_expr (e)) + if (e->expr_type == EXPR_ARRAY + && (gfc_is_constant_expr (e) || gfc_is_expandable_expr (e))) gfc_expand_constructor (e, false); } diff --git a/gcc/testsuite/gfortran.dg/PR100683.f90 b/gcc/testsuite/gfortran.dg/PR100683.f90 new file mode 100644 index 0000000..6929bb5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100683.f90 @@ -0,0 +1,36 @@ +! { dg-do run } +! +! Test the fix for PR100683 +! + +program main_p + + implicit none + + integer :: i + integer, parameter :: n = 11 + integer, parameter :: u(*) = [(i, i=1,n)] + + type :: foo_t + integer :: i + end type foo_t + + type, extends(foo_t) :: bar_t + integer :: a(n) + end type bar_t + + type(bar_t), parameter :: a(*) = [(bar_t(i, u), i=1,n)] + type(bar_t) :: b(n) = [(bar_t(i, u), i=1,n)] + + if(any(a(:)%i/=u)) stop 1 + do i = 1, n + if(any(a(i)%a/=u)) stop 2 + end do + if(any(b(:)%i/=u)) stop 3 + do i = 1, n + if(any(b(i)%a/=u)) stop 4 + end do + stop + +end program main_p +