From patchwork Fri Jun 27 08:42:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 364826 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 26BC6140080 for ; Fri, 27 Jun 2014 18:43:00 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=fxX1cOPTjEUzXsHsPj+DjmtV64hd79PyjWVt1NyrWwQOut yhyr8xte7rY69Ofx22NkJmQa8OX035nI2E4fWmK3O4UocUQk4rFZ1Bc4R8c3Pq9J 9aoAScaopt5QjhDxmaiKJ298QbNgBjzX4Qya+iYIYY2LBSzitw62fS5IKMaXA= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=d50c19f9bNhMO8fmT1dOVVPrgkY=; b=hBymFGFnPx84Y+CS93vV 3+a5MBL/XQkRM0+/pSIVdTPgU9hEVY5BsJTpTK5++NkojMACeiGegYmZRPuU+P5t WE2qDxi2rZ8CyODTuKfECn1FRpf5pKWmHqHrnbMXbTjcz0br1ahEhWhv9fyOWC0F bh+3aKRzoQJD6ad71vtp5fE= Received: (qmail 6358 invoked by alias); 27 Jun 2014 08:42:52 -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 6333 invoked by uid 89); 27 Jun 2014 08:42:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FROM_12LTRDOM autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Jun 2014 08:42:51 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X0Rk6-0002f5-Mx from Bernd_Schmidt@mentor.com ; Fri, 27 Jun 2014 01:42:46 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 27 Jun 2014 01:42:46 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Fri, 27 Jun 2014 09:42:44 +0100 Message-ID: <53AD2E5A.30509@codesourcery.com> Date: Fri, 27 Jun 2014 10:42:02 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: gfortran , GCC Patches Subject: Don't use create_tmp_var for static vars I discovered that create_tmp_var is used in the gfortran frontend to create static variables. IMO the function is not intended to do this, and it causes problems for a modification I need to make to it which assumes that it only creates local variables. So I've made a patch to make fortran directly use build_decl instead in these cases. The following was bootstrapped and tested on x86_64-linux. Ok? Bernd Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (revision 435407) +++ gcc/fortran/trans-array.c (working copy) @@ -2046,11 +2046,15 @@ gfc_build_constant_array_constructor (gf TREE_CONSTANT (init) = 1; TREE_STATIC (init) = 1; - tmp = gfc_create_var (tmptype, "A"); + tmp = build_decl (input_location, VAR_DECL, create_tmp_var_name ("A"), + tmptype); + DECL_ARTIFICIAL (tmp) = 1; + DECL_IGNORED_P (tmp) = 1; TREE_STATIC (tmp) = 1; TREE_CONSTANT (tmp) = 1; TREE_READONLY (tmp) = 1; DECL_INITIAL (tmp) = init; + pushdecl (tmp); return tmp; } Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 435407) +++ gcc/fortran/trans-decl.c (working copy) @@ -5345,11 +5345,16 @@ create_main_function (tree fndecl) TREE_STATIC (array) = 1; /* Create a static variable to hold the jump table. */ - var = gfc_create_var (array_type, "options"); + var = build_decl (input_location, VAR_DECL, + create_tmp_var_name ("options"), + array_type); + DECL_ARTIFICIAL (var) = 1; + DECL_IGNORED_P (var) = 1; TREE_CONSTANT (var) = 1; TREE_STATIC (var) = 1; TREE_READONLY (var) = 1; DECL_INITIAL (var) = array; + pushdecl (var); var = gfc_build_addr_expr (build_pointer_type (integer_type_node), var); tmp = build_call_expr_loc (input_location,