From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109683 invoked by alias); 7 Feb 2018 02:17:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109590 invoked by uid 89); 7 Feb 2018 02:17:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=vuw, 2a4, 2A4, 257391 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; Wed, 07 Feb 2018 02:17:08 +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 w172H6fM039854 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Feb 2018 18:17:06 -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 w172H6hW039853; Tue, 6 Feb 2018 18:17:06 -0800 (PST) (envelope-from sgk) Date: Wed, 07 Feb 2018 02:17:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/82049 -- resolve a charlen if possible Message-ID: <20180207021706.GA39844@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/9DWx/yDrRhgMJTb" Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-02/txt/msg00295.txt.bz2 --/9DWx/yDrRhgMJTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 816 The attached patch fixes PR fortran/82049. Prior to this patch, gfortran was fouling up the resolution of the charlen expression in the testcase. The immediately tries to resolve the length while parsing the type-spec. While here, I've introduced an optimization that causes gfc_match_type_spec() to return early if the gfortran isn't going to be getting a type-spec. This is done be peeking at the next character, if it is in [a-z], the we don't have a type spec. OK to commit? 2018-02-06 Steven G. Kargl PR fortran/82049 * match.c (gfc_match_type_spec): If the charlen is non-NULL, then try to resolve it. While here return early if possible. 2018-02-06 Steven G. Kargl PR fortran/82049 * gfortran.dg/assumed_charlen_parameter.f90: New test. -- Steve --/9DWx/yDrRhgMJTb Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr82049.diff" Content-length: 1526 Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 257391) +++ gcc/fortran/match.c (working copy) @@ -2054,11 +2054,17 @@ gfc_match_type_spec (gfc_typespec *ts) { match m; locus old_locus; - char name[GFC_MAX_SYMBOL_LEN + 1]; + char c, name[GFC_MAX_SYMBOL_LEN + 1]; gfc_clear_ts (ts); gfc_gobble_whitespace (); old_locus = gfc_current_locus; + + /* If c isn't [a-z], then return immediately. */ + c = gfc_peek_ascii_char (); + if (!ISALPHA(c)) + return MATCH_NO; + type_param_spec_list = NULL; if (match_derived_type_spec (ts) == MATCH_YES) @@ -2099,6 +2105,8 @@ gfc_match_type_spec (gfc_typespec *ts) ts->type = BT_CHARACTER; m = gfc_match_char_spec (ts); + if (ts->u.cl && ts->u.cl->length) + gfc_resolve_expr (ts->u.cl->length); if (m == MATCH_NO) m = MATCH_YES; Index: gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 =================================================================== --- gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/82049 +! Original code contributed by John Harper +program ice ! f2003 + implicit none + character(*), parameter:: a = 'ice', b = '*' + character(*), parameter:: c(2) = [character(len(a)) :: a, b] + print "(2A4)",adjustr(c) +end program ice --/9DWx/yDrRhgMJTb--