From patchwork Thu Oct 28 23:52:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 46768 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85959385780F for ; Thu, 28 Oct 2021 23:54:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85959385780F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635465244; bh=U1DEouxAtexJDaiF40MJv7N/a3kBZ1IsbNcSrCOgVEY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QUFddmUCnwou8O8stq4DAwJ1zGkLdgOzVXBdMZA6Dzi1WqCsgLPDCFbfrbw9PvTmO uXltNzPCNj1NeDlpslHs+uVcRLuwbk9d7oCNUAcJloDc4dYdJoHKSFQayKNBRnHvUi zNGWeUILgqGcyCqv7iXyccXYjh8L1Qs7ka+ybIXc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 659D13858405; Thu, 28 Oct 2021 23:53:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 659D13858405 Received: by mail-wm1-x32c.google.com with SMTP id v127so7294620wme.5; Thu, 28 Oct 2021 16:53:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U1DEouxAtexJDaiF40MJv7N/a3kBZ1IsbNcSrCOgVEY=; b=1qtm6XT5A1ntKhf/mI95VuP3hmyh2J36KHGgp0ztaJU2y72GrL/ohaUDGWXnkZNrCM 6O56nWIpMfZkucRLlRC3ep+gZlEhglabQr2w7AVSX/ODtJpIOMVNGPiDcVJXodHJHhHW p49rVplHOqXUXRDRSa7Ce2B5BzpbDjPwv9fsheZrNJZfCXe2zZW27pwAmJ4C0M5wrOU3 8vCXgaHpnzSpcblvdO7/NDctPI+1gZFlCaevpERU4HXUwoKB4L/LW4mNcK4ixyBGiIEj XA4pfTiXOrhpJLFieAkGDfxjKL9U6VZ3Zdzstr037cenSq6rJhSAJ/AHjpl0Gj8A3Z1u 5BxA== X-Gm-Message-State: AOAM53190LGXUDQhj2vvQ+8DrGEXR07NmU+n6dUEC6wYy3Vi/BpWIjru o3NMBplbBJWBTDtK9snjZ3Y= X-Google-Smtp-Source: ABdhPJy2Qic5BRb9Zb/eaZj2m/rK+Rd5W7htEnNfZl+eTmxiY+e54KfAlfC26bBTRQ/LfRRy00S2ww== X-Received: by 2002:a1c:9a96:: with SMTP id c144mr7746963wme.70.1635465198350; Thu, 28 Oct 2021 16:53:18 -0700 (PDT) Received: from nbbrfq.weghof (dynamic-2bq7di4u2lfl4qjka9-pd01.res.v6.highway.a1.net. [2001:871:227:33a8:f6a3:c58c:7641:e771]) by smtp.gmail.com with ESMTPSA id z135sm8976158wmc.45.2021.10.28.16.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 16:53:17 -0700 (PDT) Received: from b by nbbrfq.weghof with local (Exim 4.95) (envelope-from ) id 1mgFCv-005wW8-4F; Fri, 29 Oct 2021 01:53:17 +0200 To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH,Fortran 2/2] Fix write_omp_udr for user-operator REDUCTIONs Date: Fri, 29 Oct 2021 01:52:59 +0200 Message-Id: <20211028235259.1411169-2-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211028235259.1411169-1-rep.dot.nop@gmail.com> References: <20211028235259.1411169-1-rep.dot.nop@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Cc: Jakub Jelinek , Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Bernhard Reutner-Fischer Due to a typo a user operator used in a reduction was not found in the symtree so would have been written multiple times (in theory). E.g. user operator ".add." was looked up as ".ad" instead of "add". For gcc-11 branch and earlier one would - memcpy (name, udr->name, len - 1); + memcpy (name, udr->name + 1, len - 1); but for gcc-12 we have an appropriate helper already. Jakub, please take care of non-trunk branches if you want it fixed there. Cc: Jakub Jelinek gcc/fortran/ChangeLog: 2017-11-16 Bernhard Reutner-Fischer * module.c (write_omp_udr): Use gfc_get_name_from_uop. --- gcc/fortran/module.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 1328414e4f7..90ab9e275f3 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -6021,12 +6021,8 @@ write_omp_udr (gfc_omp_udr *udr) return; else { - gfc_symtree *st; - size_t len = strlen (udr->name + 1); - char *name = XALLOCAVEC (char, len); - memcpy (name, udr->name, len - 1); - name[len - 1] = '\0'; - st = gfc_find_symtree (gfc_current_ns->uop_root, name); + const char *name = gfc_get_name_from_uop (udr->name); + gfc_symtree *st = gfc_find_symtree (gfc_current_ns->uop_root, name); /* If corresponding user operator is private, don't write the UDR. */ if (st != NULL)