From patchwork Mon Jun 29 21:24:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1319333 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=Xs5bey10; dkim-atps=neutral Received: from sourceware.org (server2.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 49wgVb49CYzB3vn for ; Tue, 30 Jun 2020 07:24:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B73D3938C2B; Mon, 29 Jun 2020 21:24:34 +0000 (GMT) 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 39A2C3898530; Mon, 29 Jun 2020 21:24:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 39A2C3898530 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=anlauf@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1593465869; bh=HudDCz6+NiABZ8nbgEry2U2iPbAxRetprNLinSrO310=; h=X-UI-Sender-Class:From:To:Subject:Date; b=Xs5bey101oTwIRB8mBKps60mCiJvRTgQEZhK0WMEUvAlyxMCNu4sCKqPsGdNuF5eB pQEHSe7swI+NAFCWdkAVZwlPFoDdOa+BO0n1GirKdZ0AJZNdBQjI4sQDi2e2c1zdcT +UjaDPwffy5n8lcK3y3khoXwvZPDqMzQEqJtn4DY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.85.246] ([93.207.85.246]) by web-mail.gmx.net (3c-app-gmx-bap46.server.lan [172.19.172.116]) (via HTTP); Mon, 29 Jun 2020 23:24:28 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH, committed] PR fortran/95978 - [10/11 Regression] ICE in gfc_match_data, at fortran/decl.c:731 Date: Mon, 29 Jun 2020 23:24:28 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:CArBpb2VO+LuC/XnGHZZG05D7/nACVexv9ePq75XM17sF2kYcpTl0UAopYrLkA85FV2om XgaoCokSCkkyjkkbMV/5KS/GQu/g895fAbK2tk6HQIhUR2OEzkkFDoTu4YU7Iq5JV2dJU9iTwqru BYarf22INajCt+UpNNNQVsoX6hPPpVOcSNGnUX/u0ZLLyVOLM93a/b3F41ItkH4coD646S9Ycsm+ 8Q1aAPi8H3kI7FIHxGzGERCK+2CeRP9/ryMdPlboy1msH3fTAQz7m1gfuqKd4ZG9iNkB8Vq1EAi9 Hk= X-UI-Out-Filterresults: notjunk:1;V03:K0:0/lAc5lycNU=:ctqG1TGyV7oNitnFeIxWki Z/UpZxnSQ1DA/DU+W84Fu2pqvxEV6kcMN5qebR8yU53w2fQSXxi3DvxxY82AVnaXpC48NpMpn znmDsGKCNrUxYVcgi3u6yn6uE7zF6q/AFyKxCc6n8UW/oImmJwsfl5XAOQQDzhObSQbG67ZdV nR2h9NKO8VJG40HJr2uzw8TtTPuDzKYDTejQ5egfc59kXhEIdx4YxhX/sOKlPcHPU0vp9Y9dz jP51W+6+fo2LONoly+7MSXxUaYC7lr2ZgMcC0wD+x6jhZ7PxP2ciOHBkWaEL1OyUjzHhtZZWZ lEQ7RXCNWd6cGljq+9QiIBjD7Gn7eU6rBAHvITzR7cOCMzqJ0ycqpwALRZQ7RWHhQCx4Dlg3v 4vfFJ5brh+/S5yZvud/saFzAQhzjaIVWrDctaB/zql9TBpWvjEz52rxyZCJw0W0qjQ9nzOo6g GKDNYmpE+QmMD8Iy/vnBXdtkYPtg4GghbJMaIl2gxT+o1KQeUN8V8iXSLSIYKVlH66Kq1cb8o OrhvLaiTxSsW4Oun+P+DIG3ldevT06gPwgchfQixant+Jg5p83SZVlAymCFd2Li/nsbSVGxOH EfEF71LcyrF5JrrsCyavNmRbxkoOMsRhJriWTsbFCUhZ/ovVRLgXs5CyoKKtlkzSmrkGozOR2 m/zcYGAhJATtctLMv5YBIDukXIKWP97+Yb/vQ4BYgPbWH3Q== X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Committed as obvious on mastger. Regtested on x86_64-pc-linux-gnu. Will backport to 10-branch. Thanks, Harald PR fortran/95978 - ICE in gfc_match_data, at fortran/decl.c:731 Catch NULL pointer dereference on invalid DATA statement. gcc/fortran/ PR fortran/95978 * decl.c (gfc_match_data): Avoid NULL pointer dereference. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index ac1f63f66e0..f38def4c291 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -728,7 +728,7 @@ gfc_match_data (void) gfc_constructor *c; c = gfc_constructor_first (new_data->value->expr->value.constructor); for (; c; c = gfc_constructor_next (c)) - if (c->expr->ts.type == BT_BOZ) + if (c->expr && c->expr->ts.type == BT_BOZ) { gfc_error ("BOZ literal constant at %L cannot appear in a " "structure constructor", &c->expr->where); diff --git a/gcc/testsuite/gfortran.dg/pr95978.f90 b/gcc/testsuite/gfortran.dg/pr95978.f90 new file mode 100644 index 00000000000..47bd7067096 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95978.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/95978 - ICE in gfc_match_data, at fortran/decl.c:731 + +program p + type t + integer :: a + type(t), allocatable :: b + data c /t(1)/ ! { dg-error "Unexpected DATA statement" } + end type t +end