From patchwork Sun Sep 15 17:51:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1162492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509022-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tSdDInMp"; 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 46WcPl3KHSz9sPF for ; Mon, 16 Sep 2019 03:51:37 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=VbvqEjYSCEn41jcYPs/JYWDzLzMdbvHKrD17NQmK8wF QM6ro+TQAm/RVvkrHPeWvrEABNqvxG+GznMSBXEjORowzscgCyLUYVQNMVj+qtqO 859bOGhWwqOMYWmYBVv20StznXdbtKI2v3TwjmPGfP6hIxboEidjy/alKQsorP88 = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=AtkC+d+Bf58rym2Xc8mA/AgLolQ=; b=tSdDInMpXxDptFCqa 78YEREXY6xOvdttQLJd4idLLPjLI69uetzTfy+qEroyIPegip1j26+YAqFYdKrHA exrMxxjGMM4KHtsiLkIpYShEMndVLLI6VqLBJuv04L88AbJfaiYPUjzuLrz/M73P NC6X6JNnpwFP0mQbWOw7kTYr3M= Received: (qmail 130157 invoked by alias); 15 Sep 2019 17:51:29 -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 130141 invoked by uid 89); 15 Sep 2019 17:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy= X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Sep 2019 17:51:28 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x8FHpQjb031227 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 15 Sep 2019 10:51:26 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x8FHpQa1031226; Sun, 15 Sep 2019 10:51:26 -0700 (PDT) (envelope-from sgk) Date: Sun, 15 Sep 2019 10:51:26 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/91727 -- NULL pointer dereference Message-ID: <20190915175126.GA31193@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Committed as obvious. The patch checks for a NULL pointer dereference. In this case, it pointers to an error in the Fortran code, and so gfortran now issues an informative error message. 2019-09-15 Steven G. Kargl PR fortran/91727 * resolve.c (conformable_arrays): If array-spec is NULL, then allocate-object is a scalar. a conformability check only occurs for an array source-expr. 2019-09-15 Steven G. Kargl PR fortran/91727 * gfortran.dg/pr91727.f90: New test. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 275715) +++ gcc/fortran/resolve.c (working copy) @@ -7487,7 +7487,7 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2) for (tail = e2->ref; tail && tail->next; tail = tail->next); /* First compare rank. */ - if ((tail && e1->rank != tail->u.ar.as->rank) + if ((tail && (!tail->u.ar.as || e1->rank != tail->u.ar.as->rank)) || (!tail && e1->rank != e2->rank)) { gfc_error ("Source-expr at %L must be scalar or have the " Index: gcc/testsuite/gfortran.dg/pr91727.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91727.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr91727.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +! Code contributed by Gerhard Steinmetz. +program p + type t + class(*), allocatable :: a + end type + type(t) :: x + allocate (x%a, source=[1]) ! { dg-error "have the same rank as" } +end