From patchwork Wed Nov 9 20:17:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 17803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp541622wru; Wed, 9 Nov 2022 12:18:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM4fKtz+SrLe4snHMXYKZWe+RQJxnSbR7L3s9wksc3XCLffPQVR2pkQEcdyz8+Ov8qbr/YDQ X-Received: by 2002:a17:906:9b87:b0:733:1795:2855 with SMTP id dd7-20020a1709069b8700b0073317952855mr58518852ejc.156.1668025111867; Wed, 09 Nov 2022 12:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668025111; cv=none; d=google.com; s=arc-20160816; b=A/x7TT1n8GCMCuJ570IJGQCng0achOjvFfNact8MVGeFAQnXkCB3i9v0hD6f2aIwqv wU5/JwYGjWKAp6aIqlkNBeq3G9uI3HnrgfQ3ytmHtTOegMMVHB2BbLR+uFmcsaUzO/vm Z7aYDR/Gm807JSqQgArLKuJCftNZCvlRophBd5t0UHEB0iB25Co4mxTVMWIfGw4GczdS F5S7wWYGLmsDykdNtZI49u7V9pdO8wZxAly2yx009oXhL8OngFm8Sbe4j0aIaqDzeBVp BHAGwXhYNlrzmuHHEteoIjzc7KUq969BnEBlnCVNBheA8vQfCF3/yolpa1ysyKZ523hH 3Neg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Q6GlIQL08/IhrCWpDR1chG3LMBjK5fsHng0z93+gVDs=; b=QEGuLUzPT2Gt9kKG3ODHMvZBzSRz+RN536K/82LdzaM1tAp/MaJN2yqo9igOu8k7ja FgiO7l9P3HDkGaijAjFlOvYxGOyEiMW5LHhbwYSOWc3OYcri9lJCflVzAxC24tbjP0D6 xt9h0UlhtqteTopxigwfejjAK889diwO02PqMMSQGfFs2OlDmzMitYKORkJ1zCYLf2rx MRTpgorjH7nfyqXsIoulqRd1GAdXeSusSUvbnN3pWTIsi2E8Hga7j8WQTIPeGvZmYRAj ZfVXbfmGTPL/zPc34+1R9y9aZsKwVR/1my/FCOdy/uDbj5RfXCgvqbPpj1U/3Y8C1v8Y R2zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QvsmiVFy; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nb1-20020a1709071c8100b007ade82b9e73si17233209ejc.757.2022.11.09.12.18.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 12:18:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QvsmiVFy; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E86C13858C27 for ; Wed, 9 Nov 2022 20:18:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E86C13858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668025110; bh=Q6GlIQL08/IhrCWpDR1chG3LMBjK5fsHng0z93+gVDs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QvsmiVFyKlPZKxhBx2iC0pKCdsAZUjCAT33mWAuWoSNgM6PsnFOggtrNM5rJliblA NHpDNsYgSw6ihd72CBHfHlJMcxeWicHpswsXQ7pnl2Rd3iDGOlKTylLvaFLioZI4t4 IyCAZDA7g5jn8KgI65QrVQbblgipA87cUCZGDKuk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id 8BCE53858D20; Wed, 9 Nov 2022 20:17:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BCE53858D20 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.171] ([93.207.86.171]) by web-mail.gmx.net (3c-app-gmx-bap34.server.lan [172.19.172.104]) (via HTTP); Wed, 9 Nov 2022 21:17:43 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: avoid NULL pointer dereference on bad EQUIVALENCEs [PR107559] Date: Wed, 9 Nov 2022 21:17:43 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:OmtbVz02cfv/lfW0m5o0a7F7e+eep7s0rPNtISxyJBe7LBK/fquCzu3XTuY5JOt1rcx3z y2+cJtz8vDBYZKCZVxQcDfA3TkBW1uJkNdibOFz3GlmbAAmbr8WqWRJYmgo5N127nvvjqiIRfI7H x2n6Wj+kc4kkpYjxbEy48YARimOdbkEIQiiWyDwSm2p1zKdAYuHCtkGMvhMca/jZCPhr04wBn9Xt lCmNDbVc7qWeIS4Hjz1DlnA8ap7CbDcUqbpxWtnmrK5ghurmUFJJfNwt3Loj/xupStGiN9zHf4tM pg= UI-OutboundReport: notjunk:1;M01:P0:FvA8ARpLcZE=;gORib1xedv11HirK6cQCv7YouOF PSKCWA6m9XOg8zkDSh9/ohBtjMkeNvxRTUZBfc7FyWp7CPk0qRbo6S0zcBI8pdEhPkzaGL5HM 9w9zRquH07Av2KAB3jd8ajtF2ASVw8FWy1HNGjyuI/qjYBsFboS1RoGUPutPh0xz58VWcR+1C ogZJWx4n7s6/lt5XzbzXCWPu3TaRJFh0JCPHIUnnkNVYbi6LnOvC3f4i6oQcNPX0ALd4dq6fc 5WJQpVf4j8Iv7b0haipnsAk1t1G8Fjhuxj2+Xl9fVEgGUd84mfmheZvu1rhn9snNhPdqXheFv rIJgzqufoA7HSgbOL8NDH1OpH94bK5/7gCdb0Co2+IAnn3HGTzH/wd3pR2KabYaWZgyZIJa3O JmHbAdPwfs0HEwVctCMQDZMRZWrqKcxhqXM9D3gZPelth6U8TFEuHk0RLonBsNFBF4So6DLBL LG339iQ2TO++VzYt93QrpApShn+aFR/7rHFlzE4rV4sMfCh3058uDZI6y+XjP6K+LKFm4NvYJ llhGLRhs7ZsZGqeyT+sgOr8Re/RubMz3nrWA4I0e7hsointa8H20EGhRaog1CkiExqiGqt8Ga qP4cW3qed3r+mMAABigdn94wDcFgXNWt1acAVxUwabzbISybLlPvhyplsvQDPH+FYQFHBO+U4 LLRxmlRVZqfZLeIJwjxFCrwpXX2npAjfZaSCh580aK2VLYowoopnEWaysQ514OUrd2oVtWR5v WjZL42Y/saP37hPF7e2Ub8huV7z0otmSmNty0LGF6P2Dx1ysfon6lTfE6DF8iO6lMPoTM8zlQ tRVI+zeAij8ojDzq52zg5iGx6bMhklfQaQwOZS+1gicTA= X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749051099619334489?= X-GMAIL-MSGID: =?utf-8?q?1749051099619334489?= Dear all, I've committed an obvious patch for NULL pointer dereferences that could occur when checking EQUIVALENCEs. See also attached. Testcase by Gerhard. Regtested on x86_64-pc-linux-gnu. Pushed: https://gcc.gnu.org/g:e505f7493bed1395d121d2f53137ec11706fa42e Thanks, Harald From e505f7493bed1395d121d2f53137ec11706fa42e Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 9 Nov 2022 21:05:28 +0100 Subject: [PATCH] Fortran: avoid NULL pointer dereference on bad EQUIVALENCEs [PR107559] gcc/fortran/ChangeLog: PR fortran/107559 * resolve.cc (resolve_equivalence): Avoid NULL pointer dereference while emitting diagnostics for bad EQUIVALENCEs. gcc/testsuite/ChangeLog: PR fortran/107559 * gfortran.dg/pr107559.f90: New test. --- gcc/fortran/resolve.cc | 2 ++ gcc/testsuite/gfortran.dg/pr107559.f90 | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr107559.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 9202e2f10ad..5ff1cd070ac 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -17218,6 +17218,7 @@ resolve_equivalence (gfc_equiv *eq) "statement at %L with different type objects"; if ((object ==2 && last_eq_type == SEQ_MIXED + && last_where && !gfc_notify_std (GFC_STD_GNU, msg, first_sym->name, last_where)) || (eq_type == SEQ_MIXED && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where))) @@ -17227,6 +17228,7 @@ resolve_equivalence (gfc_equiv *eq) "statement at %L with objects of different type"; if ((object ==2 && last_eq_type == SEQ_NONDEFAULT + && last_where && !gfc_notify_std (GFC_STD_GNU, msg, first_sym->name, last_where)) || (eq_type == SEQ_NONDEFAULT && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where))) diff --git a/gcc/testsuite/gfortran.dg/pr107559.f90 b/gcc/testsuite/gfortran.dg/pr107559.f90 new file mode 100644 index 00000000000..714e236df50 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107559.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! PR fortran/107559 - ICE in resolve_equivalence +! Contributed by G.Steinmetz + +module m + implicit none + integer, protected :: a ! { dg-error "Fortran 2003: PROTECTED attribute" } + integer :: b + equivalence (a, b) ! { dg-error "has no IMPLICIT type" } +end -- 2.35.3