From patchwork Tue May 30 17:50:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 768738 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 3wch324dSVz9rvt for ; Wed, 31 May 2017 03:50:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="i3KtbZlN"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=inkQRmKjNY7VqTvfmUK6ioQZjOg3pTkfEXUtB/KsNqf4SmQua9 ZuDc9j9e/NWNeXeKb4vmjFGYY4THl+FPpqblVcHoS/yjEXSce9WgLTanHONmVR4F Q4uDwQ4hZkzMzCy98gtL48NZ3EUtDatiCZRPYL9wa+Dlmf3GEzjM/jylE= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=jMolGU/fLMzviqYst62SOgiAkjw=; b=i3KtbZlNV8iKe+TWTUzZ TLZ1RLPGEOldhZT6su01LaON/uE81rv+Ja1czlzYYm/VN3ElvIvqvYkx4GXdWByV uU0NhWnnXlaGjkSNlkiEES1bMIkj1OUvvrT6lc9nhO8YGL1WYJCsDQP8Sohu7KiC CMkwC/k3QMNQw9jbxQoJ12Q= Received: (qmail 123255 invoked by alias); 30 May 2017 17:50:08 -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 123177 invoked by uid 89); 30 May 2017 17:50:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yb0-f182.google.com Received: from mail-yb0-f182.google.com (HELO mail-yb0-f182.google.com) (209.85.213.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 May 2017 17:50:03 +0000 Received: by mail-yb0-f182.google.com with SMTP id 132so22312779ybq.1 for ; Tue, 30 May 2017 10:50:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=96ScRCgZiM6yHa7mXC+OPnXA/ZQAShb7mds+fsuHSvo=; b=bpC21kML7clwD/cYs/jRFDiaFPwwKHEPQ/b2xs6TKuGBerTm//MIKIHNNFAFoo5QGC xsAvo+4w5UnndmozaTVbEltqFx1dMbkM0rKCVTZQwVbkuFebUPtYnieyp5ixm1qYTdLh OUrBvWaJIYdPXsuT2br7y7hYSKR886sNo8S/6juB2EhClNANMH4vgBG5Bx8/oWDc3HqE yQfuY+lN4Y2PrWnrYSA/0bfMWpOUAxKmDUCJSRfkcBZr6FNovKUVoFLvNcpc+YY5rmdm MoYO4lu+sLrHL7YdTM0WKOwddRbOM/SNS1gH6lZnD1WUzQJaPs5BRY0fAM33o4fzeFI4 pu2g== X-Gm-Message-State: AODbwcD7GNa/1+wfam84ueLRPA48/ltH6soTiNhVyZcKdkLHJAFNpU/k ku2ZtBe2aOGp2w== X-Received: by 10.37.165.101 with SMTP id h92mr26167123ybi.6.1496166605619; Tue, 30 May 2017 10:50:05 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::3:eff1]) by smtp.googlemail.com with ESMTPSA id d81sm6370900ywe.41.2017.05.30.10.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 10:50:05 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] Random cleanups Message-ID: Date: Tue, 30 May 2017 13:50:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Some random cleanups. Mainly fixing stale comments and awkward whitespacing. Rename some name-lookup internal workers to the do_FOO form. natan 2017-05-30 Nathan Sidwell * cp-tree.def (OVERLOAD): Fix comment. * cp-tree.h: Fix comments and whitespace. * error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope. * name-lookup.c (add_decl_to_level): Assert not class. (check_local_shadow): Use OVL_P. (pushdecl_with_scope_1): Rename to ... (do_pushdecl_with_Scope): ... here. (do_nonmember_using_decl): Use qualified_namespace_lookup return value. (push_class_level_binding_1): Use OVL_P. (pushdecl_namespace_level): Use do_pushdecl_with_scope. (pushtag_1): Rename to ... (do_pushtag): ... here. Adjust do_pushdecl_with_scope call. (pushtag): Adjust. (store_class_bindings): Do not time here. * name-lookup.h (pushdecl_outermost_localscope): Reorder. * pt.c (listify): Declare argvec at point of initialization. Index: cp-tree.def =================================================================== --- cp-tree.def (revision 248689) +++ cp-tree.def (working copy) @@ -228,8 +228,7 @@ DEFTREECODE (DEFERRED_NOEXCEPT, "deferre member template, the template may be an IDENTIFIER_NODE. */ DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", tcc_expression, 2) -/* A list-like node for chaining overloading candidates. TREE_TYPE is - the original name, and the parameter is the FUNCTION_DECL. */ +/* One of a set of overloaded functions. */ DEFTREECODE (OVERLOAD, "overload", tcc_exceptional, 0) /* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or Index: cp-tree.h =================================================================== --- cp-tree.h (revision 248689) +++ cp-tree.h (working copy) @@ -692,7 +692,8 @@ struct GTY(()) tree_overload { tree function; }; -/* Iterator for a 1 dimensional overload. */ +/* Iterator for a 1 dimensional overload. Permits iterating over the + outer level of a 2-d overload when explicitly enabled. */ class ovl_iterator { @@ -970,7 +971,7 @@ enum GTY(()) abstract_class_use { (LANG_IDENTIFIER_CAST (NODE)->class_template_info) /* The IDENTIFIER_BINDING is the innermost cxx_binding for the - identifier. It's PREVIOUS is the next outermost binding. Each + identifier. Its PREVIOUS is the next outermost binding. Each VALUE field is a DECL for the associated declaration. Thus, name lookup consists simply of pulling off the node at the front of the list (modulo oddities for looking up the names of types, @@ -1454,6 +1455,7 @@ union GTY((desc ("cp_tree_node_structure userdef_literal; }; + /* Global state. */ struct GTY(()) saved_scope { @@ -2496,9 +2498,9 @@ struct GTY(()) lang_decl_fn { unsigned static_function : 1; unsigned pure_virtual : 1; unsigned defaulted_p : 1; - unsigned has_in_charge_parm_p : 1; unsigned has_vtt_parm_p : 1; + unsigned pending_inline_p : 1; unsigned nonconverting : 1; unsigned thunk_p : 1; Index: error.c =================================================================== --- error.c (revision 248689) +++ error.c (working copy) @@ -1146,7 +1146,7 @@ dump_decl (cxx_pretty_printer *pp, tree case SCOPE_REF: dump_type (pp, TREE_OPERAND (t, 0), flags); - pp_colon_colon (pp); + pp_cxx_colon_colon (pp); dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME); break; @@ -1193,8 +1193,7 @@ dump_decl (cxx_pretty_printer *pp, tree case OVERLOAD: if (!OVL_SINGLE_P (t)) { - t = OVL_FIRST (t); - tree ctx = CP_DECL_CONTEXT (t); + tree ctx = ovl_scope (t); if (ctx != global_namespace) { if (TYPE_P (ctx)) @@ -1203,7 +1202,7 @@ dump_decl (cxx_pretty_printer *pp, tree dump_decl (pp, ctx, flags); pp_cxx_colon_colon (pp); } - dump_decl (pp, DECL_NAME (t), flags); + dump_decl (pp, OVL_NAME (t), flags); break; } Index: name-lookup.c =================================================================== --- name-lookup.c (revision 248689) +++ name-lookup.c (working copy) @@ -120,13 +120,12 @@ find_namespace_value (tree ns, tree name static void add_decl_to_level (cp_binding_level *b, tree decl) { - /* We used to record virtual tables as if they were ordinary - variables, but no longer do so. */ - gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl))); + gcc_assert (b->kind != sk_class); - if (TREE_CODE (decl) == NAMESPACE_DECL - && !DECL_NAMESPACE_ALIAS (decl)) + if (TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl)) { + /* Inner namespaces get their own chain, to make walking + simpler. */ DECL_CHAIN (decl) = b->namespaces; b->namespaces = decl; } @@ -2132,8 +2131,7 @@ check_local_shadow (tree decl) /* Warn if a variable shadows a non-function, or the variable is a function or a pointer-to-function. */ - if ((TREE_CODE (member) != FUNCTION_DECL - && TREE_CODE (member) != OVERLOAD) + if (!OVL_P (member) || TREE_CODE (decl) == FUNCTION_DECL || TYPE_PTRFN_P (TREE_TYPE (decl)) || TYPE_PTRMEMFUNC_P (TREE_TYPE (decl))) @@ -3328,7 +3326,7 @@ push_using_decl (tree scope, tree name) closer binding level than LEVEL. */ static tree -pushdecl_with_scope_1 (tree x, cp_binding_level *level, bool is_friend) +do_pushdecl_with_scope (tree x, cp_binding_level *level, bool is_friend) { cp_binding_level *b; tree function_decl = current_function_decl; @@ -3365,7 +3363,7 @@ pushdecl_outermost_localscope (tree x) n->kind != sk_function_parms; n = b->level_chain) b = n; - tree ret = b ? pushdecl_with_scope_1 (x, b, false) : error_mark_node; + tree ret = b ? do_pushdecl_with_scope (x, b, false) : error_mark_node; timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; @@ -3436,10 +3434,6 @@ do_nonmember_using_decl (tree scope, tre name_lookup lookup (name, 0); if (!qualified_namespace_lookup (scope, &lookup)) - /* Lookup error */ - return; - - if (!lookup.value) { error ("%qD not declared", name); return; @@ -4062,7 +4056,7 @@ push_class_level_binding_1 (tree name, t } } else if (TREE_CODE (target_decl) == OVERLOAD - && is_overloaded_fn (target_bval)) + && OVL_P (target_bval)) old_decl = bval; else if (TREE_CODE (decl) == USING_DECL && TREE_CODE (bval) == USING_DECL @@ -4077,10 +4071,10 @@ push_class_level_binding_1 (tree name, t && DECL_DEPENDENT_P (bval)) return true; else if (TREE_CODE (decl) == USING_DECL - && is_overloaded_fn (target_bval)) + && OVL_P (target_bval)) old_decl = bval; else if (TREE_CODE (bval) == USING_DECL - && is_overloaded_fn (target_decl)) + && OVL_P (target_decl)) return true; if (old_decl && binding->scope == class_binding_level) @@ -4544,7 +4538,7 @@ pushdecl_namespace_level (tree x, bool i tree t; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - t = pushdecl_with_scope_1 + t = do_pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace), is_friend); /* Now, the type_shadowed stack may screw us. Munge it so it does @@ -5627,12 +5621,11 @@ maybe_process_template_type_declaration Returns TYPE upon success and ERROR_MARK_NODE otherwise. */ static tree -pushtag_1 (tree name, tree type, tag_scope scope) +do_pushtag (tree name, tree type, tag_scope scope) { - cp_binding_level *b; tree decl; - b = current_binding_level; + cp_binding_level *b = current_binding_level; while (/* Cleanup scopes are not scopes from the point of view of the language. */ b->kind == sk_cleanup @@ -5721,7 +5714,7 @@ pushtag_1 (tree name, tree type, tag_sco } else if (b->kind != sk_template_parms) { - decl = pushdecl_with_scope_1 (decl, b, /*is_friend=*/false); + decl = do_pushdecl_with_scope (decl, b, /*is_friend=*/false); if (decl == error_mark_node) return decl; @@ -5783,14 +5776,14 @@ pushtag_1 (tree name, tree type, tag_sco return type; } -/* Wrapper for pushtag_1. */ +/* Wrapper for do_pushtag. */ tree pushtag (tree name, tree type, tag_scope scope) { tree ret; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - ret = pushtag_1 (name, type, scope); + ret = do_pushtag (name, type, scope); timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } @@ -5879,7 +5872,6 @@ store_class_bindings (vecidentifier)) bindings_need_stored.safe_push (cb->identifier); @@ -5891,7 +5883,6 @@ store_class_bindings (vec *using_directives; @@ -331,8 +330,8 @@ extern void finish_namespace_using_decl extern void finish_local_using_decl (tree, tree, tree); extern void finish_namespace_using_directive (tree, tree); extern void finish_local_using_directive (tree, tree); -extern tree pushdecl_outermost_localscope (tree); extern tree pushdecl (tree, bool is_friend = false); +extern tree pushdecl_outermost_localscope (tree); extern tree pushdecl_top_level (tree, bool is_friend = false); extern tree pushdecl_top_level_and_finish (tree, tree); extern tree pushtag (tree, tree, tag_scope); Index: pt.c =================================================================== --- pt.c (revision 248689) +++ pt.c (working copy) @@ -24788,15 +24788,16 @@ static tree listify (tree arg) { tree std_init_list = get_namespace_binding (std_node, init_list_identifier); - tree argvec; + if (!std_init_list || !DECL_CLASS_TEMPLATE_P (std_init_list)) { error ("deducing from brace-enclosed initializer list requires " "#include "); return error_mark_node; } - argvec = make_tree_vec (1); + tree argvec = make_tree_vec (1); TREE_VEC_ELT (argvec, 0) = arg; + return lookup_template_class (std_init_list, argvec, NULL_TREE, NULL_TREE, 0, tf_warning_or_error); }