From patchwork Mon Mar 11 21:09:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 1054881 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-497717-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vcFEnfFx"; 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 44J9hq61F8z9s3l for ; Tue, 12 Mar 2019 08:09:30 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=jqXpT2PifRZEZSziY5V2CQ3q81x3zZV/ShNjP/7lDNg+ce FSXCbxfhzmqD3p+K44Hmp19HigZyGEThtiox36eXzxqeuYo0/VrxWIX8TBYlGa7Y 3Ks4RepJuVYCVr12fJ3UzBe7GkLakhplppaxBIxGqS5bSQ0iWdbc8O4jZYJe8= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=F82VpH/L9GSkoE2IQTNwUSZ8ih8=; b=vcFEnfFxMJhumJ01EutC wDaYnsjUJqN4oBF24bqNg/DwkjFqJhoIzBt0i39gAF57LoNnbvy0LZe94xRjHpWK huJdWLUHaE4aGwHe/ZwcbAeyrhH8CXLD/wpbfsAYYLVN8EmuMp2Mi9n4H8e/Afwh MXSMzmovX9zRuewK3FiAvUM= Received: (qmail 29473 invoked by alias); 11 Mar 2019 21:09:18 -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 29455 invoked by uid 89); 11 Mar 2019 21:09:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:f03, MATCH_YES, Reject, match_yes X-HELO: mail-oi1-f171.google.com Received: from mail-oi1-f171.google.com (HELO mail-oi1-f171.google.com) (209.85.167.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Mar 2019 21:09:16 +0000 Received: by mail-oi1-f171.google.com with SMTP id x187so295586oia.7; Mon, 11 Mar 2019 14:09:16 -0700 (PDT) MIME-Version: 1.0 From: Janus Weil Date: Mon, 11 Mar 2019 22:09:02 +0100 Message-ID: Subject: [Patch, Fortran] PR 89601: [8/9 Regression] [PDT] ICE: Segmentation fault (in resolve_component) To: gfortran , gcc-patches Hi all, the attached patch fixes an ICE-on-invalid problem with parametrized derived types, more precisely a PDT without any parameters, and regtests cleanly x86_64-linux-gnu. For the relevant standard quote, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89601#c4. Technically the ICE is a regression, but since it happens on invalid code only, backporting is not essential IMHO (but might still be useful). Ok for trunk? And 8-branch? Cheers, Janus diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1c738baedaa..5733bf2ac82 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-03-11 Janus Weil + + PR fortran/89601 + * decl.c (gfc_match_formal_arglist): Reject empty type parameter lists. + (gfc_match_derived_decl): Mark as PDT only if type parameter list was + matched successfully. + 2019-03-11 Martin Liska * decl.c (match_record_decl): Wrap an option name diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index a29e2db0bd6..39ec413a953 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6275,7 +6275,16 @@ gfc_match_formal_arglist (gfc_symbol *progname, int st_flag, } if (gfc_match_char (')') == MATCH_YES) - goto ok; + { + if (typeparam) + { + gfc_error_now ("A parameter name is required at %C"); + m = MATCH_ERROR; + goto cleanup; + } + else + goto ok; + } for (;;) { @@ -10217,13 +10226,14 @@ gfc_match_derived_decl (void) m = gfc_match_formal_arglist (sym, 0, 0, true); if (m != MATCH_YES) gfc_error_recovery (); + else + sym->attr.pdt_template = 1; m = gfc_match_eos (); if (m != MATCH_YES) { gfc_error_recovery (); gfc_error_now ("Garbage after PARAMETERIZED TYPE declaration at %C"); } - sym->attr.pdt_template = 1; } if (extended && !sym->components) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aec924f27aa..a571002772c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-03-11 Janus Weil + + PR fortran/89601 + * gfortran.dg/pdt_16.f03: Modified to avoid follow-up errors. + * gfortran.dg/pdt_30.f90: New test case. + 2019-03-11 Martin Liska * g++.dg/conversion/simd3.C (foo): Wrap option names diff --git a/gcc/testsuite/gfortran.dg/pdt_16.f03 b/gcc/testsuite/gfortran.dg/pdt_16.f03 index 067d87d660d..22c6b83a084 100644 --- a/gcc/testsuite/gfortran.dg/pdt_16.f03 +++ b/gcc/testsuite/gfortran.dg/pdt_16.f03 @@ -12,7 +12,6 @@ end program p type t(a ! { dg-error "Expected parameter list" } integer, kind :: a - real(a) :: x end type type u(a, a) ! { dg-error "Duplicate name" } integer, kind :: a ! { dg-error "already declared" } diff --git a/gcc/testsuite/gfortran.dg/pdt_30.f90 b/gcc/testsuite/gfortran.dg/pdt_30.f90 new file mode 100644 index 00000000000..d07b52f6fab --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_30.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! PR 89601: [8/9 Regression] [PDT] ICE: Segmentation fault (in resolve_component) +! +! Contributed by Arseny Solokha + +program vw + interface + real function ul (ki) + real :: ki + end function ul + end interface + type :: q8 () ! { dg-error "A parameter name is required" } + procedure (ul), pointer, nopass :: pj + end type q8 + type (q8) :: ki +end program vw