From patchwork Mon Aug 15 19:38:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 659392 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 3sCm553yfbz9t1S for ; Tue, 16 Aug 2016 05:38:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yf2XGuW/; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=uv9BV4uJ4tMD4yIl6CTYENqoVFxC4/asf0GOpdr+zfNHbC0lzo L9aCXj6AIb5op5MnVYhVsKvpLQ7z+yeYZpw4fDwGD4E7NFdQhWJXPSaqPe2sqF1l L+1auB0baUEKYrEFHq9RT01EBWWpkwJoGJi0YM4+q9ap0Q0VvCOlmG73U= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=JukWNKdXSMTXI12tEFzuxJXTfeU=; b=yf2XGuW/1uKAxZ3slR/o g9lk4hGRansp2pul/vblxtpPlF8JERhH81wfTvQjNFimmcA+ayV9fAGXvoLs+jvo GPNJNkoo0Ogj15BN62GIhNatCfPdk5N1qTf+QhzH4obNSf96s1GU3Ox+mju/eFfr AhPmuMV9K3zAuQXqJv8jDdk= Received: (qmail 118896 invoked by alias); 15 Aug 2016 19:38:39 -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 118875 invoked by uid 89); 15 Aug 2016 19:38:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=6677, 6666, rank X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Aug 2016 19:38:28 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id 294CB12989; Mon, 15 Aug 2016 21:38:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 1A41111E03; Mon, 15 Aug 2016 21:38:25 +0200 (CEST) Received: from [78.35.170.71] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.8) (envelope-from ) id 57b21a31-0bb0-7f0000012729-7f0000019de4-1 for ; Mon, 15 Aug 2016 21:38:25 +0200 Received: from [192.168.178.20] (xdsl-78-35-170-71.netcologne.de [78.35.170.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Mon, 15 Aug 2016 21:38:23 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran, committed] Set deferred flag on typespec for temporary strings Message-ID: <46935568-3b42-8429-4978-0117f3861624@netcologne.de> Date: Mon, 15 Aug 2016 21:38:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 Hello world, I just committed the attached patch as obvious and simple after regression-testing. One source of mysterious errors (and regressions) in the front end was that the deferred flag on the typespec was not set for deffered strings. Because some flags (including the deferred flag) in the typespec were not output to the dump of the Fortran AST, I have also added this. I will backport to 6 and 5 in a few days. Regards Thomas 2016-08-15 Thomas Koenig * frontend-passes.c (create_var): Set ts.deferred for deferred-length character variables. * dump-parse-tree.c (show_typespec): Also dump is_c_interop, is_iso_c and deferred flags. Index: dump-parse-tree.c =================================================================== --- dump-parse-tree.c (Revision 239218) +++ dump-parse-tree.c (Arbeitskopie) @@ -120,7 +120,15 @@ show_typespec (gfc_typespec *ts) fprintf (dumpfile, "%d", ts->kind); break; } + if (ts->is_c_interop) + fputs (" C_INTEROP", dumpfile); + if (ts->is_iso_c) + fputs (" ISO_C", dumpfile); + + if (ts->deferred) + fputs (" DEFERRED", dumpfile); + fputc (')', dumpfile); } Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 239218) +++ frontend-passes.c (Arbeitskopie) @@ -616,6 +616,7 @@ create_var (gfc_expr * e, const char *vname) gfc_code *n; gfc_namespace *ns; int i; + bool deferred; if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e)) return gfc_copy_expr (e); @@ -666,6 +667,7 @@ create_var (gfc_expr * e, const char *vname) } } + deferred = 0; if (e->ts.type == BT_CHARACTER && e->rank == 0) { gfc_expr *length; @@ -675,7 +677,10 @@ create_var (gfc_expr * e, const char *vname) if (length) symbol->ts.u.cl->length = length; else - symbol->attr.allocatable = 1; + { + symbol->attr.allocatable = 1; + deferred = 1; + } } symbol->attr.flavor = FL_VARIABLE; @@ -687,6 +692,7 @@ create_var (gfc_expr * e, const char *vname) result = gfc_get_expr (); result->expr_type = EXPR_VARIABLE; result->ts = e->ts; + result->ts.deferred = deferred; result->rank = e->rank; result->shape = gfc_copy_shape (e->shape, e->rank); result->symtree = symtree;