From patchwork Tue Nov 22 20:55:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 83506 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2310978qge; Tue, 22 Nov 2016 12:56:35 -0800 (PST) X-Received: by 10.84.210.167 with SMTP id a36mr3504002pli.125.1479848195872; Tue, 22 Nov 2016 12:56:35 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o79si30071050pfa.97.2016.11.22.12.56.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 12:56:35 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442290-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-442290-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442290-patch=linaro.org@gcc.gnu.org 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=NnyI84zBYgbsHw1X6QtRyPFe0d61/GM9zMgSpuGh++/ u4vgjFQRPf+a9zFh9FJ6J5AfTRzegNzkKBjeYMScvjvszZ7YpYZslwdrLkhuNrBJ 2fuNeYZclI5LccaqjMSS0oZiKPBTNK8sUHuFu0RDk7JMEP36Zft7aZUziB+BQyFE = 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=7mboY82rLqdYrpRg5W/aU56eFP4=; b=CfGg1VYdRHS9xTPoq cy7ps2gBl6wWIFxSjkkIxFemDialnqi3iK74S7gJ5lHRccfI3CLnUYZsc+sd+jIt bSsgYGVysUuhU5APuu/B+WPpm4NHEdO76sEfL4WUP3Ampq3VauSjNf2etMh2fBcs xUs2EG0dDNImHru6rq/hK+t+m8= Received: (qmail 2005 invoked by alias); 22 Nov 2016 20:56:12 -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 1979 invoked by uid 89); 22 Nov 2016 20:56:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=UD:cl 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; Tue, 22 Nov 2016 20:56:01 +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 uAMKtwlV092156 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Nov 2016 12:55:58 -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 uAMKtvAS092155; Tue, 22 Nov 2016 12:55:57 -0800 (PST) (envelope-from sgk) Date: Tue, 22 Nov 2016 12:55:57 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/78479 -- allocate a charlen Message-ID: <20161122205557.GA92090@troutmask.apl.washington.edu> Reply-To: kargl@uw.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) The patch and ChangeLog shuod be sufficient to explain the change. Regression tested on x86_64-*-freebsd. OK to commit? 2016-11-22 Steven G. Kargl PR fortran/78479 * expr.c (gfc_apply_init): Allocate a charlen if needed. 2016-11-22 Steven G. Kargl PR fortran/78479 * gfortran.dg/pr78479.f90: New test. -- Steve Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 242638) +++ gcc/fortran/expr.c (working copy) @@ -4132,7 +4132,12 @@ gfc_apply_init (gfc_typespec *ts, symbol { gfc_set_constant_character_len (len, ctor->expr, has_ts ? -1 : first_len); - ctor->expr->ts.u.cl->length = gfc_copy_expr (ts->u.cl->length); + if (!ctor->expr->ts.u.cl) + ctor->expr->ts.u.cl + = gfc_new_charlen (gfc_current_ns, ts->u.cl); + else + ctor->expr->ts.u.cl->length + = gfc_copy_expr (ts->u.cl->length); } } } Index: gcc/testsuite/gfortran.dg/pr78479.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr78479.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr78479.f90 (working copy) @@ -0,0 +1,6 @@ +! { dg-do compile } +program p + type t + character(3) :: c(1) = 'a' // ['b'] + end type +end