From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101776 invoked by alias); 5 Sep 2018 15:02:45 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 101600 invoked by uid 89); 5 Sep 2018 15:02:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=mm, uu, UU, MM X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Sep 2018 15:02:43 +0000 Received: by mail-wr1-f65.google.com with SMTP id u12-v6so8026350wrr.4; Wed, 05 Sep 2018 08:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PEFfP6r9wPZS86+dlZR9Zu3fDTmnX8tbtEMn3mQEcKk=; b=Fbero/t65NvHe5VpaLHIYw6OwAFyHaYsgol5b7vJZJ1kj6ZKfkgJSG5fGRhs25y7ij oIaY1yp0wyxm6yxNiyFjSKjzg4K3/YBUFdn6i2UUH/VlWJ0fBhPw/5u9qptBdTAEEFX2 2wBijv2KMdfEHVTPCCfGGXTNuih3vnDxqJQnn2Wcqo8pkiJEb6KR2VI7lq8uzAvK+fbD qFvhjOGHmv7nZkczYDvjHW1VQxOfWcb1AotgyqzNcsmC9R+ZlyTAQkIlLZxSKzsDRjkC Ewi8Hct09xLN8LszCrdDbigF1u8E3xcyo0gPnqA5M1ixAFu+vS97eDikInRCgmUQHcYF 9yNw== Return-Path: Received: from s46.loc (91-119-125-11.dsl.dynamic.surfer.at. [91.119.125.11]) by smtp.gmail.com with ESMTPSA id 139-v6sm4049625wmp.4.2018.09.05.08.02.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 08:02:40 -0700 (PDT) Received: from cow by s46.loc with local (Exim 4.91) (envelope-from ) id 1fxZFa-000089-Bd; Wed, 05 Sep 2018 14:57:46 +0000 From: Bernhard Reutner-Fischer To: fortran@gcc.gnu.org Cc: Bernhard Reutner-Fischer , gcc-patches@gcc.gnu.org Subject: [PATCH,FORTRAN 19/29] Use stringpool and unified uppercase handling for types Date: Wed, 05 Sep 2018 15:02:00 -0000 Message-Id: <20180905145732.404-20-rep.dot.nop@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00050.txt.bz2 From: Bernhard Reutner-Fischer Use the existing helper function to create type names. The helper function uses the stringpool already. gcc/fortran/ChangeLog: 2017-11-24 Bernhard Reutner-Fischer * decl.c (build_sym): Use stringpool node instead of stack variables. (gfc_match_map): Likewise. (gfc_match_union): Likewise. * trans-decl.c (gfc_trans_use_stmts): Call gfc_dt_upper_string and thus use stringpool node for the type name. --- gcc/fortran/decl.c | 25 ++++++++++--------------- gcc/fortran/trans-decl.c | 8 +++----- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 48ef5637e36..55a59008f66 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1490,7 +1490,7 @@ build_sym (const char *name, gfc_charlen *cl, bool cl_deferred, { symbol_attribute attr; gfc_symbol *sym; - int upper; + const char *upper; gfc_symtree *st; /* Symbols in a submodule are host associated from the parent module or @@ -1520,20 +1520,15 @@ build_sym (const char *name, gfc_charlen *cl, bool cl_deferred, course, this is only necessary if the upper case letter is actually different. */ - upper = TOUPPER(name[0]); - if (upper != name[0]) + upper = gfc_dt_upper_string (name); + if (upper[0] != name[0]) { - char u_name[GFC_MAX_SYMBOL_LEN + 1]; gfc_symtree *st; - - gcc_assert (strlen(name) <= GFC_MAX_SYMBOL_LEN); - strcpy (u_name, name); - u_name[0] = upper; - - st = gfc_find_symtree (gfc_current_ns->sym_root, u_name); + gcc_assert (strlen (upper) <= GFC_MAX_SYMBOL_LEN); + st = gfc_find_symtree (gfc_current_ns->sym_root, upper); /* STRUCTURE types can alias symbol names */ - if (st != 0 && st->n.sym->attr.flavor != FL_STRUCT) + if (st && st->n.sym->attr.flavor != FL_STRUCT) { gfc_error ("Symbol %qs at %C also declared as a type at %L", name, &st->n.sym->declared_at); @@ -9672,7 +9667,7 @@ gfc_match_map (void) { /* Counter used to give unique internal names to map structures. */ static unsigned int gfc_map_id = 0; - char name[GFC_MAX_SYMBOL_LEN + 1]; + const char *name; gfc_symbol *sym; locus old_loc; @@ -9687,7 +9682,7 @@ gfc_match_map (void) /* Map blocks are anonymous so we make up unique names for the symbol table which are invalid Fortran identifiers. */ - snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "MM$%u", gfc_map_id++); + name = gfc_get_string ("MM$%u", gfc_map_id++); if (!get_struct_decl (name, FL_STRUCT, &old_loc, &sym)) return MATCH_ERROR; @@ -9705,7 +9700,7 @@ gfc_match_union (void) { /* Counter used to give unique internal names to union types. */ static unsigned int gfc_union_id = 0; - char name[GFC_MAX_SYMBOL_LEN + 1]; + const char *name; gfc_symbol *sym; locus old_loc; @@ -9720,7 +9715,7 @@ gfc_match_union (void) /* Unions are anonymous so we make up unique names for the symbol table which are invalid Fortran identifiers. */ - snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "UU$%u", gfc_union_id++); + name = gfc_get_string ("UU$%u", gfc_union_id++); if (!get_struct_decl (name, FL_UNION, &old_loc, &sym)) return MATCH_ERROR; diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 6e717633a8f..023350723ff 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5053,12 +5053,10 @@ gfc_trans_use_stmts (gfc_namespace * ns) /* The following can happen if a derived type is renamed. */ if (!st) { - char *name; - name = xstrdup (rent->local_name + const char *upper; + upper = gfc_dt_upper_string (rent->local_name ? rent->local_name : rent->use_name); - name[0] = (char) TOUPPER ((unsigned char) name[0]); - st = gfc_find_symtree (ns->sym_root, name); - free (name); + st = gfc_find_symtree (ns->sym_root, upper); gcc_assert (st); } -- 2.19.0.rc1