From patchwork Thu May 24 00:24:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 919483 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-478345-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="XbCdjdkk"; 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 40rqsm0566z9s2L for ; Thu, 24 May 2018 10:25:30 +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=uZ/SD7b16PisbKzV9U6gkNHrM0Lsqu8fwWHdzCdX12I 4xI2+2y2z440kQijmSG2Q+nL6BjgHqLRUcuzYldtHNMzHjuZ69WvQgID6M3n8edv vwYr+b1D4P4UPpgn8mOk65IcEm35pjmUNsZqSsimsoyFigy2LVGBuHQeLheYiSsM = 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=leaZX3jQb2M7aWJtkOGcnOLSkVA=; b=XbCdjdkkjLOO2T+LP PdKqfuBnxa7USnD9BXg/MCrxPIxEBBVYtlnzIKUGutj6KL7h8Ix5lqQH0WWlQJ97 d+Ph0Hc4E/zyfjEZSXlVXuO6gRYEIUndqXM1FQYrY5bHY0GotUZhPSiGDj0xGV71 jimkq/xXBm9O5oIEquBMCCF8gI= Received: (qmail 14416 invoked by alias); 24 May 2018 00:25:05 -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 14186 invoked by uid 89); 24 May 2018 00:24:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients 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; Thu, 24 May 2018 00:24:22 +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 w4O0OFr6030100 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 May 2018 17:24:15 -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 w4O0OF3C030099; Wed, 23 May 2018 17:24:15 -0700 (PDT) (envelope-from sgk) Date: Wed, 23 May 2018 17:24:15 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortan/85779 -- Fix NULL pointer dereference Message-ID: <20180524002415.GA30090@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Subject says it all. OK to commit? 2018-05-23 Steven G. Kargl PR fortran/85779 *decl.c (gfc_match_derived_decl): Fix NULL point dereference. 2018-05-23 Steven G. Kargl PR fortran/85779 * gfortran.dg/pr85779_1.f90: New test. * gfortran.dg/pr85779_2.f90: Ditto. * gfortran.dg/pr85779_3.f90: Ditto. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 260623) +++ gcc/fortran/decl.c (working copy) @@ -9960,8 +9960,12 @@ gfc_match_derived_decl (void) if (!gensym->attr.generic && gensym->ts.type != BT_UNKNOWN) { - gfc_error ("Derived type name %qs at %C already has a basic type " - "of %s", gensym->name, gfc_typename (&gensym->ts)); + if (gensym->ts.u.derived) + gfc_error ("Derived type name %qs at %C already has a basic type " + "of %s", gensym->name, gfc_typename (&gensym->ts)); + else + gfc_error ("Derived type name %qs at %C already has a basic type", + gensym->name); return MATCH_ERROR; } Index: gcc/testsuite/gfortran.dg/pr85779_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85779_1.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr85779_1.f90 (working copy) @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/85779 +type(t) function f() ! { dg-error "is not accessible" } + type f ! { dg-error "already has a basic type" } + end type ! { dg-error "END FUNCTION statement" } +end Index: gcc/testsuite/gfortran.dg/pr85779_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85779_2.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr85779_2.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/85779 +type(t) function f() result(z) ! { dg-error "is not accessible" } + type z ! { dg-error "already has a basic type" } + end type ! { dg-error "END FUNCTION statement" } +end + Index: gcc/testsuite/gfortran.dg/pr85779_3.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85779_3.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr85779_3.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/85779 +class(t) function f() ! { dg-error "must be dummy, allocatable or pointer" } + type f ! { dg-error "already has a basic type" } + end type ! { dg-error "END FUNCTION statement" } +end +