From patchwork Tue Oct 27 16:47:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 536745 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 8FE5F141373 for ; Wed, 28 Oct 2015 03:48:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=u738ZMa6; 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=HraQrvvvGP9MifdX5yUHYGe2FRf4BeLXtzW4DKblD7msWlnxkyDZF EBLrBLd54XDfPPbIrLKIqWV6Th+EkmcsQxbk/UC1dFy236BWNDNA4uJRAQ1t+7YL vy7Tkh8WcXPVqpvRd96cX2tmxRRT/ZVipmCqyNoHXKXMDMH6JZYq18= 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=ArjwlJ6iVSMzO61IsWoMrR9yAaA=; b=u738ZMa6YrQxaBo35hbF EWRKhf5MjlEkVyQKbWR25ocvbomwmuAx8kKf/RH5rZBmHZEwCTziJt8E7pMtgm3A x8WxscD2N85PUzeugw9V4oonK3YV5QJQEFeq+wPJG2yO+1mCQTD1kzW1ZmEbgCB+ obVaQILYQDSB0H9Ew4vv2kI= Received: (qmail 14707 invoked by alias); 27 Oct 2015 16:47:43 -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 14611 invoked by uid 89); 27 Oct 2015 16:47:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, 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; Tue, 27 Oct 2015 16:47:40 +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 t9RGlcPe016970 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 27 Oct 2015 09:47:38 -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 t9RGlcY3016969; Tue, 27 Oct 2015 09:47:38 -0700 (PDT) (envelope-from sgk) Date: Tue, 27 Oct 2015 09:47:38 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH, committed] PR fortran/68108 -- Check for valid array ref. Message-ID: <20151027164738.GA16960@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) I've committed the attached patch after testing on x86_64-*-freebsd. A regression was introduced by my fix for PR fortran/67805, which failed to check for a valid array ref. Note, Mikael approved the patch in the PR audit trail. 2015-10-27 Steven G. Kargl PR fortran/68108 * decl.c (char_len_param_value): Check for REF_ARRAY. 2015-10-27 Steven G. Kargl PR fortran/68108 * gfortran.dg/pr67805_2.f90: New test. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 229445) +++ gcc/fortran/decl.c (working copy) @@ -748,13 +748,15 @@ char_len_param_value (gfc_expr **expr, b /* This catches the invalid code "[character(m(2:3)) :: 'x', 'y']", which causes an ICE if gfc_reduce_init_expr() is called. */ - if (e->ref && e->ref->u.ar.type == AR_UNKNOWN + if (e->ref && e->ref->type == REF_ARRAY + && e->ref->u.ar.type == AR_UNKNOWN && e->ref->u.ar.dimen_type[0] == DIMEN_RANGE) goto syntax; gfc_reduce_init_expr (e); - if ((e->ref && e->ref->u.ar.type != AR_ELEMENT) + if ((e->ref && e->ref->type == REF_ARRAY + && e->ref->u.ar.type != AR_ELEMENT) || (!e->ref && e->expr_type == EXPR_ARRAY)) { gfc_free_expr (e); Index: gcc/testsuite/gfortran.dg/pr67805_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr67805_2.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr67805_2.f90 (working copy) @@ -0,0 +1,22 @@ +! { dg-do compile } +! PR fortran/68108 +! Code contributed by Juergen Reuter (juergen.reuter at desy dot de) +! Test fix for regression caused by PR fortran/67805. +module lexers + implicit none + type :: template_t + character(256) :: charset1 + integer :: len1 + end type template_t + +contains + + subroutine match_quoted (tt, s, n) + type(template_t), intent(in) :: tt + character(*), intent(in) :: s + integer, intent(out) :: n + character(tt%len1) :: ch1 + ch1 = tt%charset1 + end subroutine match_quoted + +end module lexers