From patchwork Tue Jun 16 17:17:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 485095 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 F00DF1401EF for ; Wed, 17 Jun 2015 03:17:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wY7ofI28; 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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=UipTqHlabRDgbggtffXfDk8BPSJm278mM3rX1JHdZGVTga viL0RR24rDtxNVxpYU/U0/Yt1uuFhx1nuYId+l72UPHe0JwUWidx+yTVT+oJFdSp HUKwHHb3GhyMO82FBhBJPi/jAzTIQ7O/jQ6sfUkcksi5/qhWPdKxJq1v5WPPo= 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=M8jDta2ADL/QU3dnyO+HY6eQcwo=; b=wY7ofI28IQYwPeqq0klo erKaVn3xUHPoeFQ9UyPIurZtDx7IHj1qgGnr4v3e+WCYZmtD7h4SgnKSWxcFa1dy d1XZKY+dmE7qGgQ9By9zljN/fbbZEKQUSrYBDSAV74T9IDso5b3brnVrID6TR/yZ lFRzD2k3eUCU0J4eQyXVX00= Received: (qmail 56442 invoked by alias); 16 Jun 2015 17:17:32 -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 56430 invoked by uid 89); 16 Jun 2015 17:17:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 16 Jun 2015 17:17:29 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5E150B82C6 for ; Tue, 16 Jun 2015 17:17:28 +0000 (UTC) Received: from [10.10.50.141] (unused [10.10.50.141] (may be forged)) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5GHHRr5006780 for ; Tue, 16 Jun 2015 13:17:27 -0400 Message-ID: <55805A27.4000007@redhat.com> Date: Tue, 16 Jun 2015 13:17:27 -0400 From: Andrew MacLeod User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches Subject: [patch 2/5] Remove tree.h compilation dependency for tm.h X-IsSubscribed: yes There are 2 macros defined in tree.h the depend on the definition of NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL. These are ANON_AGGRNAME_FORMAT and ANON_AGGRNAME_P. This means that in order to get the correct values for those macros, you have to be sure that tm.h was included before tree.h, and thats the only conditional dependency tree.h has on tm.h. By changing those 2 macos to functions and defining them in tree.c, the restriction/requirement is removed. These are not heavily used, Im sure compilation issues are unmeasurable. There is also single hard compilation dependency on the definition of TARGET_DLLIMPORT_DECL_ATTRIBUTES. it shows: #if TARGET_DLLIMPORT_DECL_ATTRIBUTES /* Given two Windows decl attributes lists, possibly including dllimport, return a list of their union . */ extern tree merge_dllimport_decl_attributes (tree, tree); /* Handle a "dllimport" or "dllexport" attribute. */ extern tree handle_dll_attribute (tree *, tree, tree, int, bool *); #endif defaults.h provides a default definition of 0, but I'm not convinced that we need to hide function prototypes like this... Anything that cares will be checking that macro before calling or creating those functions... and if they don't there will be an unresolved external at compilation time.. so we still get an error. We also don't get any errors if the prototype isn't used. If it is not protected, then it removes the need to have defaults.h and tm.h included before tree.h This patch makes both these changes, and tree.h no longer requires tm.h or defaults.h bootstraps on x86_64-unknown-linux-gnu with no new regressions. No failures on config-list.mk target runs either. OK for trunk? Andrew * tree.h (merge_dllimport_decl_attributes, handle_dll_attribute): Remove conditional exposure of prototypes. (ANON_AGGRNAME_FORMAT, ANON_AGGRNAME_P): Delete. * tree.c (anon_aggrname_format, anon_aggrname_p): New. Replace macro defintions in tree.h with functions. * lto-streamer-out.c (DFS_write_tree_body, hash_tree): Use anon_aggrname_p. * tree-streamer-out.c (write_ts_decl_minimal_tree_pointers): Likewise. * cp/cp-lang.c (cxx_dwarf_name): Use anon_aggrname_p. * cp/cp-tree.h (TYPE_ANONYMOUS_P): Likewise. * cp/decl.c (grokdeclarator, xref_tag_1): Likewise. * cp/error.c (dump_aggr_type): likewise. * cp/pt.c (push_template_decl_real): Likewise. * cp/name-lookup.c (make_anon_name): Use anon_aggrname_format. Index: tree.h =================================================================== *** tree.h (revision 224345) --- tree.h (working copy) *************** extern tree remove_attribute (const char *** 3988,4001 **** extern tree merge_attributes (tree, tree); - #if TARGET_DLLIMPORT_DECL_ATTRIBUTES /* Given two Windows decl attributes lists, possibly including dllimport, return a list of their union . */ extern tree merge_dllimport_decl_attributes (tree, tree); /* Handle a "dllimport" or "dllexport" attribute. */ extern tree handle_dll_attribute (tree *, tree, tree, int, bool *); - #endif /* Returns true iff unqualified CAND and BASE are equivalent. */ --- 3988,3999 ---- *************** target_opts_for_fn (const_tree fndecl) *** 4899,4921 **** /* For anonymous aggregate types, we need some sort of name to hold on to. In practice, this should not appear, but it should not be harmful if it does. */ ! #ifndef NO_DOT_IN_LABEL ! #define ANON_AGGRNAME_FORMAT "._%d" ! #define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '.' \ ! && IDENTIFIER_POINTER (ID_NODE)[1] == '_') ! #else /* NO_DOT_IN_LABEL */ ! #ifndef NO_DOLLAR_IN_LABEL ! #define ANON_AGGRNAME_FORMAT "$_%d" ! #define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '$' \ ! && IDENTIFIER_POINTER (ID_NODE)[1] == '_') ! #else /* NO_DOLLAR_IN_LABEL */ ! #define ANON_AGGRNAME_PREFIX "__anon_" ! #define ANON_AGGRNAME_P(ID_NODE) \ ! (!strncmp (IDENTIFIER_POINTER (ID_NODE), ANON_AGGRNAME_PREFIX, \ ! sizeof (ANON_AGGRNAME_PREFIX) - 1)) ! #define ANON_AGGRNAME_FORMAT "__anon_%d" ! #endif /* NO_DOLLAR_IN_LABEL */ ! #endif /* NO_DOT_IN_LABEL */ /* The tree and const_tree overload templates. */ namespace wi --- 4897,4904 ---- /* For anonymous aggregate types, we need some sort of name to hold on to. In practice, this should not appear, but it should not be harmful if it does. */ ! extern const char *anon_aggrname_format(); ! extern bool anon_aggrname_p (const_tree); /* The tree and const_tree overload templates. */ namespace wi Index: tree.c =================================================================== *** tree.c (revision 224345) --- tree.c (working copy) *************** clean_symbol_name (char *p) *** 9258,9263 **** --- 9258,9299 ---- *p = '_'; } + /* For anonymous aggregate types, we need some sort of name to + hold on to. In practice, this should not appear, but it should + not be harmful if it does. */ + bool + anon_aggrname_p(const_tree id_node) + { + #ifndef NO_DOT_IN_LABEL + return (IDENTIFIER_POINTER (id_node)[0] == '.' + && IDENTIFIER_POINTER (id_node)[1] == '_'); + #else /* NO_DOT_IN_LABEL */ + #ifndef NO_DOLLAR_IN_LABEL + return (IDENTIFIER_POINTER (id_node)[0] == '$' \ + && IDENTIFIER_POINTER (id_node)[1] == '_'); + #else /* NO_DOLLAR_IN_LABEL */ + #define ANON_AGGRNAME_PREFIX "__anon_" + return (!strncmp (IDENTIFIER_POINTER (id_node), ANON_AGGRNAME_PREFIX, + sizeof (ANON_AGGRNAME_PREFIX) - 1)); + #endif /* NO_DOLLAR_IN_LABEL */ + #endif /* NO_DOT_IN_LABEL */ + } + + /* Return a format for an anonymous aggregate name. */ + const char * + anon_aggrname_format() + { + #ifndef NO_DOT_IN_LABEL + return "._%d"; + #else /* NO_DOT_IN_LABEL */ + #ifndef NO_DOLLAR_IN_LABEL + return "$_%d"; + #else /* NO_DOLLAR_IN_LABEL */ + return "__anon_%d"; + #endif /* NO_DOLLAR_IN_LABEL */ + #endif /* NO_DOT_IN_LABEL */ + } + /* Generate a name for a special-purpose function. The generated name may need to be unique across the whole link. Changes to this function may also require corresponding changes to Index: lto-streamer-out.c =================================================================== *** lto-streamer-out.c (revision 224345) --- lto-streamer-out.c (working copy) *************** DFS::DFS_write_tree_body (struct output_ *** 740,746 **** /* Drop names that were created for anonymous entities. */ if (DECL_NAME (expr) && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE ! && ANON_AGGRNAME_P (DECL_NAME (expr))) ; else DFS_follow_tree_edge (DECL_NAME (expr)); --- 740,746 ---- /* Drop names that were created for anonymous entities. */ if (DECL_NAME (expr) && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE ! && anon_aggrname_p (DECL_NAME (expr))) ; else DFS_follow_tree_edge (DECL_NAME (expr)); *************** hash_tree (struct streamer_tree_cache_d *** 1180,1186 **** /* Drop names that were created for anonymous entities. */ if (DECL_NAME (t) && TREE_CODE (DECL_NAME (t)) == IDENTIFIER_NODE ! && ANON_AGGRNAME_P (DECL_NAME (t))) ; else visit (DECL_NAME (t)); --- 1180,1186 ---- /* Drop names that were created for anonymous entities. */ if (DECL_NAME (t) && TREE_CODE (DECL_NAME (t)) == IDENTIFIER_NODE ! && anon_aggrname_p (DECL_NAME (t))) ; else visit (DECL_NAME (t)); Index: tree-streamer-out.c =================================================================== *** tree-streamer-out.c (revision 224345) --- tree-streamer-out.c (working copy) *************** write_ts_decl_minimal_tree_pointers (str *** 603,609 **** /* Drop names that were created for anonymous entities. */ if (DECL_NAME (expr) && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE ! && ANON_AGGRNAME_P (DECL_NAME (expr))) stream_write_tree (ob, NULL_TREE, ref_p); else stream_write_tree (ob, DECL_NAME (expr), ref_p); --- 603,609 ---- /* Drop names that were created for anonymous entities. */ if (DECL_NAME (expr) && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE ! && anon_aggrname_p (DECL_NAME (expr))) stream_write_tree (ob, NULL_TREE, ref_p); else stream_write_tree (ob, DECL_NAME (expr), ref_p); Index: cp/cp-lang.c =================================================================== *** cp/cp-lang.c (revision 224345) --- cp/cp-lang.c (working copy) *************** cxx_dwarf_name (tree t, int verbosity) *** 120,126 **** gcc_assert (DECL_P (t)); if (DECL_NAME (t) ! && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDA_TYPE_P (t))) return NULL; if (verbosity >= 2) return decl_as_dwarf_string (t, --- 120,126 ---- gcc_assert (DECL_P (t)); if (DECL_NAME (t) ! && (anon_aggrname_p (DECL_NAME (t)) || LAMBDA_TYPE_P (t))) return NULL; if (verbosity >= 2) return decl_as_dwarf_string (t, Index: cp/cp-tree.h =================================================================== *** cp/cp-tree.h (revision 224345) --- cp/cp-tree.h (working copy) *************** enum languages { lang_c, lang_cplusplus, *** 1335,1341 **** /* Nonzero if NODE has no name for linkage purposes. */ #define TYPE_ANONYMOUS_P(NODE) \ ! (OVERLOAD_TYPE_P (NODE) && ANON_AGGRNAME_P (TYPE_LINKAGE_IDENTIFIER (NODE))) /* The _DECL for this _TYPE. */ #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE))) --- 1335,1341 ---- /* Nonzero if NODE has no name for linkage purposes. */ #define TYPE_ANONYMOUS_P(NODE) \ ! (OVERLOAD_TYPE_P (NODE) && anon_aggrname_p (TYPE_LINKAGE_IDENTIFIER (NODE))) /* The _DECL for this _TYPE. */ #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE))) Index: cp/decl.c =================================================================== *** cp/decl.c (revision 224345) --- cp/decl.c (working copy) *************** grokdeclarator (const cp_declarator *dec *** 10390,10396 **** /* Replace the anonymous name with the real name everywhere. */ for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) { ! if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (t))) /* We do not rename the debug info representing the anonymous tagged type because the standard says in [dcl.typedef] that the naming applies only for --- 10390,10396 ---- /* Replace the anonymous name with the real name everywhere. */ for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) { ! if (anon_aggrname_p (TYPE_IDENTIFIER (t))) /* We do not rename the debug info representing the anonymous tagged type because the standard says in [dcl.typedef] that the naming applies only for *************** xref_tag_1 (enum tag_types tag_code, tre *** 12291,12297 **** /* In case of anonymous name, xref_tag is only called to make type node and push name. Name lookup is not required. */ ! if (ANON_AGGRNAME_P (name)) t = NULL_TREE; else t = lookup_and_check_tag (tag_code, name, --- 12291,12297 ---- /* In case of anonymous name, xref_tag is only called to make type node and push name. Name lookup is not required. */ ! if (anon_aggrname_p (name)) t = NULL_TREE; else t = lookup_and_check_tag (tag_code, name, Index: cp/error.c =================================================================== *** cp/error.c (revision 224345) --- cp/error.c (working copy) *************** dump_aggr_type (cxx_pretty_printer *pp, *** 678,684 **** name = DECL_NAME (name); } ! if (name == 0 || ANON_AGGRNAME_P (name)) { if (flags & TFF_CLASS_KEY_OR_ENUM) pp_string (pp, M_("")); --- 678,684 ---- name = DECL_NAME (name); } ! if (name == 0 || anon_aggrname_p (name)) { if (flags & TFF_CLASS_KEY_OR_ENUM) pp_string (pp, M_("")); Index: cp/name-lookup.c =================================================================== *** cp/name-lookup.c (revision 224345) --- cp/name-lookup.c (working copy) *************** make_anon_name (void) *** 2097,2103 **** { char buf[32]; ! sprintf (buf, ANON_AGGRNAME_FORMAT, anon_cnt++); return get_identifier (buf); } --- 2097,2103 ---- { char buf[32]; ! sprintf (buf, anon_aggrname_format (), anon_cnt++); return get_identifier (buf); } Index: cp/pt.c =================================================================== *** cp/pt.c (revision 224345) --- cp/pt.c (working copy) *************** push_template_decl_real (tree decl, bool *** 4795,4801 **** if (DECL_CLASS_SCOPE_P (decl)) member_template_p = true; if (TREE_CODE (decl) == TYPE_DECL ! && ANON_AGGRNAME_P (DECL_NAME (decl))) { error ("template class without a name"); return error_mark_node; --- 4795,4801 ---- if (DECL_CLASS_SCOPE_P (decl)) member_template_p = true; if (TREE_CODE (decl) == TYPE_DECL ! && anon_aggrname_p (DECL_NAME (decl))) { error ("template class without a name"); return error_mark_node;