From patchwork Wed Nov 16 20:50:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 21254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp55477wrr; Wed, 16 Nov 2022 12:50:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf4It9AP+ry/PfOY+SE93WLZoEaFZR44GTB5+9XWrlNa1HPrY3Uq32XxvD6Rz9eNhyLhZbj6 X-Received: by 2002:aa7:df93:0:b0:458:cd82:91a with SMTP id b19-20020aa7df93000000b00458cd82091amr20233562edy.15.1668631859088; Wed, 16 Nov 2022 12:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668631859; cv=none; d=google.com; s=arc-20160816; b=MYXj/RAPmIXdhtqoWz7DjvStNHBqxJ0eLLzaEBHOYoTrmz1XsK7N40Ga/X2TVCSiXr m1i7Axm4la0XZP0Li5K/Sw4S+Kik9jL3Sv0y5EE9QV+ZY2GPYPC0/0ZyJ/SoLRLBKN8I Gan+l311aalauZkIn5ioxIdboGywL5iK5o1p4I3BIhwUfWVBwXQo8tvvbhdCoIRxpmRk EaFkY996g1cMx/64TtnmGoo7ShL952AG4+xn7ZeIHLj2joBtmzYRtSl1SFBo6vK40eZ8 CR1rQeaxSfs6yXMODF/xIstza+V0IGQovQh+v/BbQKdI0t4Ied1ewmq3MGAAN0+SIObA LMaA== 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=yjLb6q8WymXOqqibABqWIOUQvKTFBPM6293/dsinhZQ=; b=RyynDByPM4VL0TjNI+nZcEf5EO9GNPPstV1/akFapOXD1vExP0iO8MCzkqExWRtkHm EcvvJxt/Y/mMqLXGDBo36wEHa6eFXtDCsGPTtDP3jEQWbWP+yNiQdAWa4BfuO9rob86T h4Gl+59PtscddFWP0wnp8mxHvmWqfO8nZ2E5F/r4XWq+dWhPEDwZwtG6UK3T5dZfwSQV gDsB9p/LzHrvRLrDJ+9xSdxmQTneY3qGtb+RTZsvRtjDdMHqd3bLQbweY0VkIr5AnB5C rbZcJh+STWqUzzWFrTSTcpGd/k4EORIAqbD/Xyh5y9Wne/lbMQP6lowtDuVl6+e6ZUcY X8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ns18IpS6; 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 b7-20020a056402350700b00451e0d930dfsi16995352edd.497.2022.11.16.12.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 12:50:59 -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=Ns18IpS6; 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 1251F396D829 for ; Wed, 16 Nov 2022 20:50:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1251F396D829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668631858; bh=yjLb6q8WymXOqqibABqWIOUQvKTFBPM6293/dsinhZQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ns18IpS6F+FtMpLA47lBi1GI5ZvTHovHRobmC1RE/mIEdvGIHgcam4dVbyw/NoK4W VQrKvaiXEDnmZc0Ja3MzrGGsZ+OpdH0pMs7jAeTvwinhYTRxXja03KmBKDoRnQmo7U 19AoWd9XCXIpPb0KkB7O1ILeVRHs6H9wXeVST9UQ= 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.21]) by sourceware.org (Postfix) with ESMTPS id 6193C396D826; Wed, 16 Nov 2022 20:50:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6193C396D826 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.187] ([93.207.86.187]) by web-mail.gmx.net (3c-app-gmx-bap19.server.lan [172.19.172.89]) (via HTTP); Wed, 16 Nov 2022 21:50:13 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: error recovery after reference to bad CLASS variable [PR107681] Date: Wed, 16 Nov 2022 21:50:13 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:DgnUVe08aLO5T/sWIelnmJMBjLB9o703ibckEBotqEIeLLSRo+mXxLlX3vuezQj8Wh6I7 NmUPoNY0gnldxouayPtJ2VUR9fYJN30A0quItvUfWBtO8lIC0X1EUQ9sZeUdtw6tCEjRjgn3JyuC 0qGl6FsMdMt8XcskW4JE9FiSkjhdGb4RTAa9lIAMklJz88yE7zgHe8c1SP3slsSrRw7I9nI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IL_FROM, GIT_PATCH_0, 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?1749687320103606647?= X-GMAIL-MSGID: =?utf-8?q?1749687320103606647?= Dear all, the attached obvious patch fixes a NULL pointer dereference when referencing a CLASS variable with a bad decl. Pushed as r13-4107-g96e4244ef3ccf4867ca4e37fbc6800e64ef30af6 after regtesting on x86_64-pc-linux-gnu. Thanks, Harald From 96e4244ef3ccf4867ca4e37fbc6800e64ef30af6 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 16 Nov 2022 21:41:19 +0100 Subject: [PATCH] Fortran: error recovery after reference to bad CLASS variable [PR107681] gcc/fortran/ChangeLog: PR fortran/107681 * resolve.cc (resolve_fl_var_and_proc): Prevent NULL pointer dereference with reference to bad CLASS variable. gcc/testsuite/ChangeLog: PR fortran/107681 * gfortran.dg/pr107681.f90: New test. --- gcc/fortran/resolve.cc | 1 + gcc/testsuite/gfortran.dg/pr107681.f90 | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr107681.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 5ff1cd070ac..24e5aa03556 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -12967,6 +12967,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) && sym->ts.u.derived && !sym->attr.select_type_temporary && !UNLIMITED_POLY (sym) + && CLASS_DATA (sym)->ts.u.derived && !gfc_type_is_extensible (CLASS_DATA (sym)->ts.u.derived)) { gfc_error ("Type %qs of CLASS variable %qs at %L is not extensible", diff --git a/gcc/testsuite/gfortran.dg/pr107681.f90 b/gcc/testsuite/gfortran.dg/pr107681.f90 new file mode 100644 index 00000000000..0999ad92649 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107681.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! PR fortran/107681 - ICE in gfc_type_is_extensible +! Contributed by G.Steinmetz + +program p + type t + integer, allocatable :: a + end type + class(t) :: x[*] ! { dg-error "must be dummy, allocatable or pointer" } + associate (y => x) ! { dg-error "Invalid array reference" } + end associate +end -- 2.35.3