From patchwork Wed Dec 12 00:56:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1011481 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-492184-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="p4CJFhHN"; 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 43Dz0149s8z9s47 for ; Wed, 12 Dec 2018 11:56:15 +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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=w/X4nAbuZNl2SIm5KpHJwR/RC8fgXpp1fb1FGOow8q3 axVH2MKjxANHsAb8ftrGlrAhLDvYKeuSwrSmD4ZydCsgGXR2JNc459f0gdpDoWUY ios/owQVQX32Nb+KDmX/HvyleFXnJTSbMxV+0FsFPoTNz6YOA6q2+/NEl0AJRLEc = 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=L4cJa62sghqdQw+bnPhREweCsoI=; b=p4CJFhHNL6Tf9zX00 +gZJ/IsVVhdy6CPQUO3fCxhHeYtONn20udn3YwV5Zae8DZY+dA2mGgX8RNepEPLP 6lHoyXd8fqL6rO5RqWavz6zfbcDlw3ebzVB4KLeZBY/adqJSXWPDM3ZYc1w1B1Ek Pqu0U/2jyHGS69B+YkQLED4i38= Received: (qmail 77074 invoked by alias); 12 Dec 2018 00:56:08 -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 76739 invoked by uid 89); 12 Dec 2018 00:56:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 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; Wed, 12 Dec 2018 00:56:06 +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 wBC0u4tV005153 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 11 Dec 2018 16:56:04 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id wBC0u42o005152; Tue, 11 Dec 2018 16:56:04 -0800 (PST) (envelope-from sgk) Date: Tue, 11 Dec 2018 16:56:04 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/88155 -- Avoid NULL pointer reference Message-ID: <20181212005604.GA5125@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Committed as obvious. The attached patch set an expression locus to gfc_current_locus to avoid a NULL pointer reference when emitting an error message. On beneficial fallout to this patch required a fix up to the testcase gfortran.dg/pr70870_1.f90. 2018-12-11 Steven G. Kargl PR fortran/88155 * primary.c (gfc_match_structure_constructor): Set the locus of an expression to avoid a NULL pointer dereference. 2018-12-11 Steven G. Kargl PR fortran/88155 * gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu. * gfortran.dg/pr88155.f90: New test. Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (revision 267034) +++ gcc/fortran/primary.c (working copy) @@ -3212,6 +3212,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_ e = gfc_get_expr (); e->symtree = symtree; e->expr_type = EXPR_FUNCTION; + e->where = gfc_current_locus; gcc_assert (gfc_fl_struct (sym->attr.flavor) && symtree->n.sym->attr.flavor == FL_PROCEDURE); Index: gcc/testsuite/gfortran.dg/pr70870_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr70870_1.f90 (revision 267034) +++ gcc/testsuite/gfortran.dg/pr70870_1.f90 (working copy) @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=gnu" } ! PR fortran/70870 ! Contributed by Vittorio Zecca type t Index: gcc/testsuite/gfortran.dg/pr88155.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr88155.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr88155.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +program p + type t + integer :: a + end type + type(t) :: x + data x /t()1/ ! { dg-error "No initializer for component" } + print *, x +end