From patchwork Fri Sep 25 19:13:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 522959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 E2D2B140775 for ; Sat, 26 Sep 2015 05:13:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dIpMmfkk; dkim-atps=neutral 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:mime-version:content-type; q=dns; s= default; b=JdwP6ii9k0fNkC1HFhdQQqbxUxlRpxDdGd2na2MaaMBUvHfEIbmMe QcpIvDiArrMUJzuvIiXYMpCOAbtU6Mmx+wLYqbMAV/z0Sukj72JwtzpD468pNSE/ byUTczhkENcnPD9OefPZ4nXlzuT1uAwOdyRf2eBPqARwsKpIemtoSs= 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:mime-version:content-type; s= default; bh=avvIqMZvWI60Tk/WFsJNZUzRPTc=; b=dIpMmfkkI4G39Hv/Xus2 EVlveFIR0LwqWlV5bdc6rcbP2SrsQ+ueoQ2bpM4upyM5CGqcQbpeskou0cRp7ELv gOOSpsV7jiN4/la/6ptfeV7J53DkWi6K1nmGSMIiFaAqu3hio4BICO2129PUV2MO ALHnLD7yz4UkeNDOIi9ZtyI= Received: (qmail 60462 invoked by alias); 25 Sep 2015 19:13:17 -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 60442 invoked by uid 89); 25 Sep 2015 19:13:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_05, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 25 Sep 2015 19:13:14 +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 t8PJDCLT094044 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 25 Sep 2015 12:13:12 -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 t8PJDCU0094043; Fri, 25 Sep 2015 12:13:12 -0700 (PDT) (envelope-from sgk) Date: Fri, 25 Sep 2015 12:13:12 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] fortran/67525 -- fix ICE in SELECT TYPE Message-ID: <20150925191312.GA94019@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) The follwoing patch has been built and regression tested on x86_64-*-freebsd. There were no regression. The patch removes an assert, which allows gfortran to detect an invalid selector in SELECT TYPE statement. 2015-09-25 Steven G. Kargl PR fortran/67525 * parse.c (match_deferred_characteristics): Remove an assert, which allows an invalid SELECT TYPE selector to be detected. 2015-09-25 Steven G. Kargl PR fortran/67525 * gfortran.dg/pr67525.f90: New test. Index: fortran/parse.c =================================================================== --- fortran/parse.c (revision 228061) +++ fortran/parse.c (working copy) @@ -3113,15 +3113,18 @@ match_deferred_characteristics (gfc_type static void check_function_result_typed (void) { - gfc_typespec* ts = &gfc_current_ns->proc_name->result->ts; + gfc_typespec ts; gcc_assert (gfc_current_state () == COMP_FUNCTION); - gcc_assert (ts->type != BT_UNKNOWN); + + if (!gfc_current_ns->proc_name->result) return; + + ts = gfc_current_ns->proc_name->result->ts; /* Check type-parameters, at the moment only CHARACTER lengths possible. */ /* TODO: Extend when KIND type parameters are implemented. */ - if (ts->type == BT_CHARACTER && ts->u.cl && ts->u.cl->length) - gfc_expr_check_typed (ts->u.cl->length, gfc_current_ns, true); + if (ts.type == BT_CHARACTER && ts.u.cl && ts.u.cl->length) + gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true); } Index: testsuite/gfortran.dg/pr67525.f90 =================================================================== --- testsuite/gfortran.dg/pr67525.f90 (revision 0) +++ testsuite/gfortran.dg/pr67525.f90 (working copy) @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/67525 +! Code contributed by Gerhard Steinmetz +! +real function f(x) + select type (x) ! { dg-error "shall be polymorphic" } + end select +end function f + +real function g(x) + select type (x=>null()) ! { dg-error "shall be polymorphic" } + end select +end function g + +subroutine a(x) + select type (x) ! { dg-error "shall be polymorphic" } + end select +end subroutine a