From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by sourceware.org (Postfix) with ESMTPS id B310F3857B9B; Thu, 8 Jun 2023 05:57:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B310F3857B9B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-55b00ad09feso164404eaf.1; Wed, 07 Jun 2023 22:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686203842; x=1688795842; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4iAg2TuiI2NdNOOZcb9z6HpGZUcKtdmBxUXr8Pxa+UU=; b=DqVm8rLNHLOACue1xzVnFWRHoy8BjpRUtVGYaxEQLO7hlOFq80bCJj/flUE58BV/aD icSQzcoFxGZpWck7TBTAg7tvvIMerLvwMwjF1lCOLJx0EpmwOjmZ1PS8F85ian0DxxOt 4x4k0YsGkkQqAowsgpd8wnItJKLq/UZZr5pwWXIHFeLZ6gN2O0eERQUPzxq3Y62qO8LR DsNbKyM2U3L+9Frq9yI2a7gD4zf2jHRDpIkSL27cRGfHeCEMT0uLmSBANFuYaBcjiyZr w7A8c0dDMFzJyzYC6QbYX2dhqPTN8xw6OfKn7V8ss4M0HeCVVr+zmHtIsCNSZABUsiM7 v0XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686203842; x=1688795842; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4iAg2TuiI2NdNOOZcb9z6HpGZUcKtdmBxUXr8Pxa+UU=; b=UqIu3x1FPaNPzgOYvZpNrLfupAoqOievP7boU2dYG78xBTbYOMwK16xdY1bSmSkPi0 yI9efroUFFqwOfD8cbgzZS8Nt+vAXq/wYbCl/fh/T7P8Z1zTqkloCA42Ng3lnimErF48 l417f6lqJpVCv9Q/bdua9n3HgJP60+XDKFrO0wgptS8aThdATvbyqdBmdXVVEov4yEWS 6qxpLswHIcGApEGfrVueEoCWZbB//c4ASYFsZOT7ouhbdbM89A5cHne2ADl1D7YJk9Jk AtU9bFbt/fLCVGYnVe+qsIvcZZNNMASQtep8/lrJCwcO3BmXysM+Ub7W0RVhDnaR8Xcx Fy1Q== X-Gm-Message-State: AC+VfDxTPbjdU/QjFjcoTDy5CMkge/HNAG1KkSj1I9gChbALo1APajrG hkRrgXpxGyuC1Tc7gpXGK/kZ0+F/W/Upw3jLByU= X-Google-Smtp-Source: ACHHUZ51T7FY5XYsc7ffMnHq0Zxm/faF74xvqRespvkbUe3CLnEb2HB6VCjC/jItU6umSrqTORc+xjYT2dqX4CaHxrc= X-Received: by 2002:a05:6808:3a1:b0:383:e7c8:4000 with SMTP id n1-20020a05680803a100b00383e7c84000mr7137618oie.13.1686203841842; Wed, 07 Jun 2023 22:57:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Paul Richard Thomas Date: Thu, 8 Jun 2023 06:57:10 +0100 Message-ID: Subject: Re: [Patch, fortran] PR87477 - (associate) - [meta-bug] [F03] issues concerning the ASSOCIATE statement To: Harald Anlauf Cc: "fortran@gcc.gnu.org" , gcc-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Harald, In answer to your question: void gfc_replace_expr (gfc_expr *dest, gfc_expr *src) { free_expr0 (dest); *dest = *src; free (src); } So it does indeed do the job. I should perhaps have remarked that, following the divide error, gfc_simplify_expr was returning a mutilated version of the expression and this was somehow connected with successfully simplifying the parentheses. Copying and replacing on no errors deals with the problem. Thanks Paul On Wed, 7 Jun 2023 at 19:38, Harald Anlauf wrote: > > Hi Paul! > > On 6/7/23 18:10, Paul Richard Thomas via Gcc-patches wrote: > > Hi All, > > > > Three more fixes for PR87477. Please note that PR99350 was a blocker > > but, as pointed out in comment #5 of the PR, this has nothing to do > > with the associate construct. > > > > All three fixes are straight forward and the .diff + ChangeLog suffice > > to explain them. 'rankguessed' was made redundant by the last PR87477 > > fix. > > > > Regtests on x86_64 - good for mainline? > > > > Paul > > > > Fortran: Fix some more blockers in associate meta-bug [PR87477] > > > > 2023-06-07 Paul Thomas > > > > gcc/fortran > > PR fortran/99350 > > * decl.cc (char_len_param_value): Simplify a copy of the expr > > and replace the original if there is no error. > > This seems to lack a gfc_free_expr (p) in case the gfc_replace_expr > is not executed, leading to a possible memleak. Can you check? > > @@ -1081,10 +1082,10 @@ char_len_param_value (gfc_expr **expr, bool > *deferred) > if (!gfc_expr_check_typed (*expr, gfc_current_ns, false)) > return MATCH_ERROR; > > - /* If gfortran gets an EXPR_OP, try to simplify it. This catches things > - like CHARACTER(([1])). */ > - if ((*expr)->expr_type == EXPR_OP) > - gfc_simplify_expr (*expr, 1); > + /* Try to simplify the expression to catch things like > CHARACTER(([1])). */ > + p = gfc_copy_expr (*expr); > + if (gfc_is_constant_expr (p) && gfc_simplify_expr (p, 1)) > + gfc_replace_expr (*expr, p); > else > gfc_free_expr (p); > > > * gfortran.h : Remove the redundant field 'rankguessed' from > > 'gfc_association_list'. > > * resolve.cc (resolve_assoc_var): Remove refs to 'rankguessed'. > > > > PR fortran/107281 > > * resolve.cc (resolve_variable): Associate names with constant > > or structure constructor targets cannot have array refs. > > > > PR fortran/109451 > > * trans-array.cc (gfc_conv_expr_descriptor): Guard expression > > character length backend decl before using it. Suppress the > > assignment if lhs equals rhs. > > * trans-io.cc (gfc_trans_transfer): Scalarize transfer of > > associate variables pointing to a variable. Add comment. > > * trans-stmt.cc (trans_associate_var): Remove requirement that > > the character length be deferred before assigning the value > > returned by gfc_conv_expr_descriptor. Also, guard the backend > > decl before testing with VAR_P. > > > > gcc/testsuite/ > > PR fortran/99350 > > * gfortran.dg/pr99350.f90 : New test. > > > > PR fortran/107281 > > * gfortran.dg/associate_5.f03 : Changed error message. > > * gfortran.dg/pr107281.f90 : New test. > > > > PR fortran/109451 > > * gfortran.dg/associate_61.f90 : New test > > Otherwise LGTM. > > Thanks for the patch! > > Harald > > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein