From patchwork Tue Dec 10 13:04:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1207078 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515600-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GFGQbTic"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47XKyb3Vckz9sR0 for ; Wed, 11 Dec 2019 00:04:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=Cd+kkilwGDvJYv4E/tq/dCC7Thf9/ejbFBLREvvpNDHicytsvx lNo8jNw/VRpbwb0CG9FgSi3gGkADUfjItAuEZQ7PftweaHU3EIbg93N62xUVKAHh ehV6C3fCNa691N7ep0ex5KdhJ5G2d+Yhkfw7vl/l/SQzu/qxwaOIPjt+U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=+NAVodhxOXdRUtc1YilMJ+fA6RM=; b=GFGQbTicU2LNN00aYuj0 Vz3er2s0TJTLqE5dtr7xl4pTPCmEL0kp6/hfsJqYNQaX8HL9T8SEwjK3MDkQaDCS hSwmbfD3Z9C2dy02PiKk7WxN64HOJZynhsRsc9adDLavVEkw3DpadxUow31Y1zED 1GSTV7Z9+wiAldKWQ8HYerI= Received: (qmail 127173 invoked by alias); 10 Dec 2019 13:04:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 127156 invoked by uid 89); 10 Dec 2019 13:04:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 13:04:08 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18DECABC4; Tue, 10 Dec 2019 13:04:06 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Bail out in gfc_dep_compare_expr for a NULL argument. To: gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org Message-ID: Date: Tue, 10 Dec 2019 14:04:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The patch is about early bail out in gfc_dep_compare_expr function when one of the arguments (and not both at the same time) is null. I'm not sure, it's a proper fix however. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/fortran/ChangeLog: 2019-12-10 Martin Liska PR fortran/92874 * dependency.c (gfc_dep_compare_expr): Bail out when one of the arguments is null. gcc/testsuite/ChangeLog: 2019-12-10 Martin Liska PR fortran/92874 * gfortran.dg/pr92874.f90: New test. --- gcc/fortran/dependency.c | 2 ++ gcc/testsuite/gfortran.dg/pr92874.f90 | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr92874.f90 diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 394d85b48a2..eb741137d60 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -319,6 +319,8 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) if (e1 == NULL && e2 == NULL) return 0; + else if (e1 == NULL || e2 == NULL) + return -2; e1 = gfc_discard_nops (e1); e2 = gfc_discard_nops (e2); diff --git a/gcc/testsuite/gfortran.dg/pr92874.f90 b/gcc/testsuite/gfortran.dg/pr92874.f90 new file mode 100644 index 00000000000..a1fca3d7718 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr92874.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-O2" } +! PR fortran/92874 +program p + call s('a') + call s('abc') +end +subroutine s(x) + character(*) :: x + print *, (x(1:1) == x(1:)) +end