From patchwork Thu Aug 22 09:59:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 269004 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 43BC52C00C4 for ; Thu, 22 Aug 2013 19:59:48 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=NuyCJTWD8rcKIuHN4pmZzuau+Rkp/ZeM/ozIvyzEiMVrQPBcX0xJd 1FBT2ke2WJ+aw7bnYCdDR4FzQxtmJZ6SR6KBd09WmqTRyhGEV6L7KzdM/i7Y5qW5 Vfo6f3MFMBb+GdiRiZ0HypmRDPelAFI+bbqkpER3MvItyI5x9VelCs= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=tghgvH4JO3WzAwwzbrBGkS4kNOw=; b=NFbcN/p2qwgESdPRMhEP +QRXZW6KNOZfto5yE0IGwhYsJGPRWJeosgp1zqIPXeZQatx+me3Y6nlD3Dx9dAGY ougg28Ou6jMal1zGA2nhLmf9Py7NulANf0n2Py7j0dPKWi/zfkT46j3yO9LX+wnm uiJ73G2PGkaTlhAk0qZUvQI= Received: (qmail 1919 invoked by alias); 22 Aug 2013 09:59:41 -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 1906 invoked by uid 89); 22 Aug 2013 09:59:41 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.2 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 22 Aug 2013 09:59:39 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 40E74543B64; Thu, 22 Aug 2013 11:59:37 +0200 (CEST) Date: Thu, 22 Aug 2013 11:59:37 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: [C++ patch] Move FINAL flag to middle-end trees. Message-ID: <20130822095937.GF16124@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, this patch moves CLASSTYPE_FINAL and DECL_FINAL_P to middle end trees, so I can use them in my type inheritance analysis. Incrementally I would like to introduce DECL_CPP_CONSTURCTOR_P/DESTRUCTOR, too, since we need to know about their C++ specific semantics. However I failed to follow the same patch, since these predicates are often called on TEMPLATE_DECL. I wonder if those can ever be ctors/dtors? Bootstrapped/regtested x86_64-linux, OK? * cp-tree.h (CLASSTYPE_FINAL): Define using TYPE_FINAL_P. (DECL_FINAL_P): Remove. * pt.c (instantiate_class_template_1): Guard that CLASSTYPE_FINAL is called on CLASS_TYPE_P. * tree.h (TYPE_FINAL_P, DECL_FINAL_P): New macros. (tree_decl_with_vis): Add FINAL field. Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 201910) +++ cp/cp-tree.h (working copy) @@ -1535,7 +1535,7 @@ struct GTY((variable_size)) lang_type { /* Nonzero means that NODE (a class type) is final */ #define CLASSTYPE_FINAL(NODE) \ - (LANG_TYPE_CLASS_CHECK (NODE)->is_final) + TYPE_FINAL_P (NODE) /* Nonzero means that this _CLASSTYPE node overloads operator=(X&). */ @@ -2400,10 +2400,6 @@ struct GTY((variable_size)) lang_decl { an override virt-specifier */ #define DECL_OVERRIDE_P(NODE) (TREE_LANG_FLAG_0 (NODE)) -/* True (in a FUNCTION_DECL) if NODE is a function declared with - a final virt-specifier */ -#define DECL_FINAL_P(NODE) (TREE_LANG_FLAG_1 (NODE)) - /* The thunks associated with NODE, a FUNCTION_DECL. */ #define DECL_THUNKS(NODE) \ (DECL_VIRTUAL_P (NODE) ? LANG_DECL_FN_CHECK (NODE)->context : NULL_TREE) Index: cp/pt.c =================================================================== --- cp/pt.c (revision 201910) +++ cp/pt.c (working copy) @@ -8730,7 +8730,8 @@ instantiate_class_template_1 (tree type) /* Adjust visibility for template arguments. */ determine_visibility (TYPE_MAIN_DECL (type)); } - CLASSTYPE_FINAL (type) = CLASSTYPE_FINAL (pattern); + if (CLASS_TYPE_P (type)) + CLASSTYPE_FINAL (type) = CLASSTYPE_FINAL (pattern); pbinfo = TYPE_BINFO (pattern); Index: tree.h =================================================================== --- tree.h (revision 201910) +++ tree.h (working copy) @@ -715,6 +715,9 @@ struct GTY(()) tree_base { DECL_NONLOCAL_FRAME in VAR_DECL + + TYPE_FINAL_P in + RECORD_TYPE, UNION_TYPE and QUAL_UNION_TYPE */ struct GTY(()) tree_typed { @@ -2314,6 +2317,10 @@ enum cv_qualifier #define TYPE_CONTAINS_PLACEHOLDER_INTERNAL(NODE) \ (TYPE_CHECK (NODE)->type_common.contains_placeholder_bits) +/* Nonzero if RECORD_TYPE represents a final derivation of class. */ +#define TYPE_FINAL_P(NODE) \ + (RECORD_OR_UNION_CHECK (NODE)->base.default_def_flag) + /* The debug output functions use the symtab union field to store information specific to the debugging format. The different debug output hooks store different types in the union field. These three @@ -3224,7 +3231,9 @@ struct GTY(()) tree_decl_with_vis { unsigned init_priority_p : 1; /* Used by C++ only. Might become a generic decl flag. */ unsigned shadowed_for_var_p : 1; - /* 14 unused bits. */ + /* Belong to FUNCTION_DECL exclusively. */ + unsigned final : 1; + /* 13 unused bits. */ }; extern tree decl_debug_expr_lookup (tree); @@ -3474,6 +3483,11 @@ extern vec **decl_debug_arg #define DECL_FUNCTION_VERSIONED(NODE)\ (FUNCTION_DECL_CHECK (NODE)->function_decl.versioned_function) +/* In FUNCTION_DECL that represent an virtual method this is set when + the method is final. */ +#define DECL_FINAL_P(NODE)\ + (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.final) + /* FUNCTION_DECL inherits from DECL_NON_COMMON because of the use of the arguments/result/saved_tree fields by front ends. It was either inherit FUNCTION_DECL from non_common, or inherit non_common from FUNCTION_DECL,