From patchwork Thu Nov 10 10:20:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 60340 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C746E383469A for ; Thu, 10 Nov 2022 10:21:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C746E383469A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668075672; bh=5i5BTzKeyOa3UuSSj/kcRyLd2TCw5a9A24XYNdmxbZY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=cq5kqsi+2fXZYflVLhhYZMP2bLA+hNPhD3s1JIEPbRnUw5mpP6nkUKFxUAB501PXy TGMtnNebQvQCe+8gnCDJMlnPw/PzWlbpuJv/SyQ3TsezWkzBucfY0uD7uNYHoRNoz3 NVX8eZjDI41fhPsc0Q/KC6kYx/T8mt2q/9tTua14= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id B9B853858C5E; Thu, 10 Nov 2022 10:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B9B853858C5E Received: by mail-ej1-x633.google.com with SMTP id ft34so3671626ejc.12; Thu, 10 Nov 2022 02:20:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5i5BTzKeyOa3UuSSj/kcRyLd2TCw5a9A24XYNdmxbZY=; b=hnV1TA6Efr1DVm5DAQ6HEcdudi9I9u7Cm1vBP37eKHE3p8b3EeHKOSNhYo+xP0gWgM IaADOii2jHId13qLwaG4a2Sud2rh9nXS8/m0tAOgVbcCmYW7aLP4n2FSmOmUGpzE4e4w FxQdaNHn/J0wAtBJ1iDXqFKDBckcLISpfCgmUnPmzIjHuTlAWZe5StUyXfm9MasmbrL0 hFsQnVC95BzWFdQomZK06J99DXIQwRldaxlKiAN6jgNhW/s1MuhHI4ljsnQ9zzwbxBqe /27f1APt4R7X0nqpWxjMf4NhO6sgxouszxRFPbILMp0PpEoj+6dg8CzLzJn9RL6uPBov 7D4Q== X-Gm-Message-State: ACrzQf1pFL5Lb0jlJJj08aWpk+RoHGfH+pVNrhodUADhMk6Vk9RjJ6Tl yZs/JUtYYlezGAHC5yDcyDA= X-Google-Smtp-Source: AMsMyM7VVl+Xxj10FmIQK6bsPWQNqTDQzsP7HnSHpHLHieXP8WGrykV50BJ+GJzVWQaSnctAYHUGnA== X-Received: by 2002:a17:906:2681:b0:783:6a92:4c38 with SMTP id t1-20020a170906268100b007836a924c38mr58872969ejc.75.1668075633896; Thu, 10 Nov 2022 02:20:33 -0800 (PST) Received: from nbbrfq (80-110-214-113.static.upcbusiness.at. [80.110.214.113]) by smtp.gmail.com with ESMTPSA id 18-20020a170906211200b00781ea761407sm6990895ejt.161.2022.11.10.02.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 02:20:33 -0800 (PST) X-Google-Original-From: Bernhard Reutner-Fischer Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1ot4fg-005jMr-2J; Thu, 10 Nov 2022 11:20:32 +0100 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , Bernhard Reutner-Fischer , gfortran ML Subject: [PATCH 1/2] Fortran: Cleanup struct ext_attr_t Date: Thu, 10 Nov 2022 11:20:30 +0100 Message-Id: <20221110102031.1366016-2-aldot@gcc.gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221110102031.1366016-1-aldot@gcc.gnu.org> References: <20221110102031.1366016-1-aldot@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tiny cleanup opportunity since we now have ext_attr_args in struct symbol_attribute. Bootstrapped and regtested on x86_64-unknown-linux with no new regressions. Ok for trunk if the prerequisite was approved ([PATCH 2/2] Fortran: add attribute target_clones) ? gcc/fortran/ChangeLog: * gfortran.h (struct ext_attr_t): Remove middle_end_name. * trans-decl.cc (add_attributes_to_decl): Move building tree_list to ... * decl.cc (gfc_match_gcc_attributes): ... here. Add the attribute to the tree_list for the middle end. Cc: gfortran ML --- gcc/fortran/decl.cc | 35 +++++++++++++++++++++++------------ gcc/fortran/gfortran.h | 1 - gcc/fortran/trans-decl.cc | 13 +------------ 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 3a619dbdd34..d312d4812b6 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -11802,15 +11802,15 @@ gfc_match_gcc_attribute_args (bool require_string, bool allow_multiple) } const ext_attr_t ext_attr_list[] = { - { "dllimport", EXT_ATTR_DLLIMPORT, "dllimport" }, - { "dllexport", EXT_ATTR_DLLEXPORT, "dllexport" }, - { "cdecl", EXT_ATTR_CDECL, "cdecl" }, - { "stdcall", EXT_ATTR_STDCALL, "stdcall" }, - { "fastcall", EXT_ATTR_FASTCALL, "fastcall" }, - { "no_arg_check", EXT_ATTR_NO_ARG_CHECK, NULL }, - { "deprecated", EXT_ATTR_DEPRECATED, NULL }, - { "target_clones",EXT_ATTR_TARGET_CLONES,NULL }, - { NULL, EXT_ATTR_LAST, NULL } + { "dllimport", EXT_ATTR_DLLIMPORT }, + { "dllexport", EXT_ATTR_DLLEXPORT }, + { "cdecl", EXT_ATTR_CDECL }, + { "stdcall", EXT_ATTR_STDCALL }, + { "fastcall", EXT_ATTR_FASTCALL, }, + { "no_arg_check", EXT_ATTR_NO_ARG_CHECK }, + { "deprecated", EXT_ATTR_DEPRECATED }, + { "target_clones",EXT_ATTR_TARGET_CLONES }, + { NULL, EXT_ATTR_LAST } }; /* Match a !GCC$ ATTRIBUTES statement of the form: @@ -11854,6 +11854,20 @@ gfc_match_gcc_attributes (void) gfc_error ("Unknown attribute in !GCC$ ATTRIBUTES statement at %C"); return MATCH_ERROR; } + + /* Check for errors. + If everything is fine, add attributes the middle-end has to know about. + */ + if (!gfc_add_ext_attribute (&attr, (ext_attr_id_t)id, &gfc_current_locus)) + return MATCH_ERROR; + else if (id == EXT_ATTR_DLLIMPORT + || id == EXT_ATTR_DLLEXPORT + || id == EXT_ATTR_CDECL + || id == EXT_ATTR_STDCALL + || id == EXT_ATTR_FASTCALL) + attr.ext_attr_args + = chainon (attr.ext_attr_args, + build_tree_list (get_identifier (name), NULL_TREE)); else if (id == EXT_ATTR_TARGET_CLONES) { attr_args @@ -11864,9 +11878,6 @@ gfc_match_gcc_attributes (void) build_tree_list (get_identifier (name), attr_args)); } - if (!gfc_add_ext_attribute (&attr, (ext_attr_id_t)id, &gfc_current_locus)) - return MATCH_ERROR; - gfc_gobble_whitespace (); ch = gfc_next_ascii_char (); if (ch == ':') diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index ce0cb61e647..c4deec0d5b8 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -847,7 +847,6 @@ typedef struct { const char *name; unsigned id; - const char *middle_end_name; } ext_attr_t; diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 24cbd4cda28..7d5d2bdbb37 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -1436,18 +1436,7 @@ gfc_add_assign_aux_vars (gfc_symbol * sym) static tree add_attributes_to_decl (symbol_attribute sym_attr, tree list) { - unsigned id; - tree attr; - - for (id = 0; id < EXT_ATTR_NUM; id++) - if (sym_attr.ext_attr & (1 << id) && ext_attr_list[id].middle_end_name) - { - attr = build_tree_list ( - get_identifier (ext_attr_list[id].middle_end_name), - NULL_TREE); - list = chainon (list, attr); - } - /* Add attribute args. */ + /* Add attributes and their arguments. */ if (sym_attr.ext_attr_args != NULL_TREE) list = chainon (list, sym_attr.ext_attr_args);