From patchwork Thu Jun 29 14:14:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 782310 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 3wz1rC2qmJz9s75 for ; Fri, 30 Jun 2017 00:14:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ogNt1enl"; 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=TPwiTBxK3w/A69n3Usyu4/zgVEGOrNBjnVWCxjptvnyUGKvGa9 hP3vJ/rx9HYgdYBwKyuAy0UkN08fGscv04T2IO5EadKbLmOlf4oN5ciC8ckQv36p a9QoYr24IoCuFAyC/87add7XfiF9oufySnoTYdwTBEZtLvDwMWODEnldE= 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=XYakM8L6BV7DG85WYR7WkQbpPik=; b=ogNt1enlG5CqaNHPt+Bl TBDw9eTda8TQYNGLInZDLw+qnJu5ImIxOjeOfIhM/Cr3qWP+ta8iLor4hQ9F2Lp8 ga3sLYZC/1a9AyVKt6DUXRmSKPl9pyW7E/T26fOk8luzearBwqk+TdaHJj4uUz0e WuTSybmMK5wVh1RdDQkDNoc= Received: (qmail 2571 invoked by alias); 29 Jun 2017 14:14:25 -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 1468 invoked by uid 89); 29 Jun 2017 14:14:24 -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-f169.google.com Received: from mail-yb0-f169.google.com (HELO mail-yb0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Jun 2017 14:14:21 +0000 Received: by mail-yb0-f169.google.com with SMTP id v197so3312476ybv.3 for ; Thu, 29 Jun 2017 07:14:21 -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=ajgTyIH3F2HqebbxYMmZ0lhIWIfqrNAsPui5jGacGfs=; b=sUae5pkVNpn36tTWgkKPVNN6K8unY19hrkqczT0In4OV2G/AyLJ4bJ21H3XTIIqOHQ Uy/QkrnTQaZGONX6q485KvVOEIsJ9AOlYr0VUCIM6xbiqLsMI/EZ818VJTAPnUT4McmO gutXhLW57ncAhK7hXmezi80+7UFJz+xn0UlKc5L3I/HDj4+cnJ/5NLcJP75VLjtLchT/ cloK88vmkcaU7rfrW8Wf0NR5OeM0KmARGw5/0YG2dBAOF1mVQKxT672Y4WXVtQvIkNhm Cz77fJQjGy3u7QQfHprkpxlmZN+DH1BObmuANVUBn9IykRIg0zYvD+jm9KDKSAcrMu5s EjBw== X-Gm-Message-State: AKS2vOymZtBVQRXf7M0CRErXaCrX34fynVXW3Ha5nwAiDyTy41r+a+Tp nF7u37HrJHJztg== X-Received: by 10.37.170.51 with SMTP id s48mr12604661ybi.153.1498745659873; Thu, 29 Jun 2017 07:14:19 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::1:9018]) by smtp.googlemail.com with ESMTPSA id d2sm2091273ywb.53.2017.06.29.07.14.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 07:14:19 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] whitespace cleanups Message-ID: Date: Thu, 29 Jun 2017 10:14:17 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 A bunch of minor reformatting and cleanups I'd collected. Applied to trunk. nathan 2017-06-29 Nathan Sidwell Whitespace cleanups. * call.c (name_as_c_string): Move CONST_CAST to return. (build_new_method_call_1): Remove unneeded bracing. * class.c (include_empty_classes): Unbreak line. * constraint.cc (tsubst_check_constraint): Add space. * cp-tree.h (lang_decl_ns): Add comment. (PTRMEM_CST_MEMBER): Break line. * decl.c (grokfndecl): Add blank lines. Unbreak some others. (grokdeclarator): Remove lines, move declaration to first use. * decl2.c (decl_needed_p): Fix indentation. (c_parse_final_cleanups): Remove blank line. * method.c (implicitly_declare_fn): Move declaration to first use. * search.c (current_scope): Add blank lines. Index: call.c =================================================================== --- call.c (revision 249779) +++ call.c (working copy) @@ -8878,7 +8878,7 @@ build_special_member_call (tree instance static char * name_as_c_string (tree name, tree type, bool *free_p) { - char *pretty_name; + const char *pretty_name; /* Assume that we will not allocate memory. */ *free_p = false; @@ -8886,7 +8886,7 @@ name_as_c_string (tree name, tree type, if (IDENTIFIER_CDTOR_P (name)) { pretty_name - = CONST_CAST (char *, identifier_to_locale (IDENTIFIER_POINTER (constructor_name (type)))); + = identifier_to_locale (IDENTIFIER_POINTER (constructor_name (type))); /* For a destructor, add the '~'. */ if (IDENTIFIER_DTOR_P (name)) { @@ -8905,9 +8905,9 @@ name_as_c_string (tree name, tree type, *free_p = true; } else - pretty_name = CONST_CAST (char *, identifier_to_locale (IDENTIFIER_POINTER (name))); + pretty_name = identifier_to_locale (IDENTIFIER_POINTER (name)); - return pretty_name; + return CONST_CAST (char *, pretty_name); } /* Build a call to "INSTANCE.FN (ARGS)". If FN_P is non-NULL, it will @@ -9118,11 +9118,10 @@ build_new_method_call_1 (tree instance, &candidates, complain); } else - { - add_candidates (fns, first_mem_arg, user_args, optype, - explicit_targs, template_only, conversion_path, - access_binfo, flags, &candidates, complain); - } + add_candidates (fns, first_mem_arg, user_args, optype, + explicit_targs, template_only, conversion_path, + access_binfo, flags, &candidates, complain); + any_viable_p = false; candidates = splice_viable (candidates, false, &any_viable_p); Index: class.c =================================================================== --- class.c (revision 249779) +++ class.c (working copy) @@ -6295,8 +6295,7 @@ include_empty_classes (record_layout_inf because we are willing to overlay multiple bases at the same offset. However, now we need to make sure that RLI is big enough to reflect the entire class. */ - eoc = end_of_class (rli->t, - CLASSTYPE_AS_BASE (rli->t) != NULL_TREE); + eoc = end_of_class (rli->t, CLASSTYPE_AS_BASE (rli->t) != NULL_TREE); rli_size = rli_size_unit_so_far (rli); if (TREE_CODE (rli_size) == INTEGER_CST && tree_int_cst_lt (rli_size, eoc)) Index: constraint.cc =================================================================== --- constraint.cc (revision 249779) +++ constraint.cc (working copy) @@ -1580,7 +1580,7 @@ tsubst_check_constraint (tree t, tree ar /* Substitute through by building an template-id expression and then substituting into that. */ - tree expr = build_nt(TEMPLATE_ID_EXPR, tmpl, targs); + tree expr = build_nt (TEMPLATE_ID_EXPR, tmpl, targs); ++processing_template_decl; tree result = tsubst_expr (expr, args, complain, in_decl, false); --processing_template_decl; Index: cp-tree.h =================================================================== --- cp-tree.h (revision 249779) +++ cp-tree.h (working copy) @@ -2556,7 +2556,9 @@ struct GTY(()) lang_decl_ns { vec *usings; vec *inlinees; - /* Map from IDENTIFIER nodes to DECLS. */ + /* Map from IDENTIFIER nodes to DECLS. It'd be nice to have this + inline, but as the hash_map has a dtor, we can't then put this + struct into a union (until moving to c++11). */ hash_map *bindings; }; @@ -4312,7 +4314,8 @@ more_aggr_init_expr_args_p (const aggr_i /* For a pointer-to-member constant `X::Y' this is the _DECL for `Y'. */ -#define PTRMEM_CST_MEMBER(NODE) (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member) +#define PTRMEM_CST_MEMBER(NODE) \ + (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member) /* The expression in question for a TYPEOF_TYPE. */ #define TYPEOF_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (TYPEOF_TYPE_CHECK (NODE))) Index: decl.c =================================================================== --- decl.c (revision 249779) +++ decl.c (working copy) @@ -8502,9 +8502,11 @@ grokfndecl (tree ctype, /* Allocate space to hold the vptr bit if needed. */ SET_DECL_ALIGN (decl, MINIMUM_METHOD_BOUNDARY); } + DECL_ARGUMENTS (decl) = parms; for (t = parms; t; t = DECL_CHAIN (t)) DECL_CONTEXT (t) = decl; + /* Propagate volatile out from type to decl. */ if (TYPE_VOLATILE (type)) TREE_THIS_VOLATILE (decl) = 1; @@ -8524,13 +8526,11 @@ grokfndecl (tree ctype, break; } - if (friendp - && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR) + if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR) { if (funcdef_flag) - error - ("defining explicit specialization %qD in friend declaration", - orig_declarator); + error ("defining explicit specialization %qD in friend declaration", + orig_declarator); else { tree fns = TREE_OPERAND (orig_declarator, 0); @@ -9132,7 +9132,6 @@ build_ptrmemfunc_type (tree type) this method instead of type_hash_canon, because it only does a simple equality check on the list of field members. */ - t = TYPE_PTRMEMFUNC_TYPE (type); if (t) return t; @@ -10068,8 +10067,6 @@ grokdeclarator (const cp_declarator *dec { case BIT_NOT_EXPR: { - tree type; - if (innermost_code != cdk_function) { error ("declaration of %qD as non-function", decl); @@ -10082,7 +10079,7 @@ grokdeclarator (const cp_declarator *dec return error_mark_node; } - type = TREE_OPERAND (decl, 0); + tree type = TREE_OPERAND (decl, 0); if (TYPE_P (type)) type = constructor_name (type); name = identifier_to_locale (IDENTIFIER_POINTER (type)); Index: decl2.c =================================================================== --- decl2.c (revision 249779) +++ decl2.c (working copy) @@ -1992,12 +1992,14 @@ decl_needed_p (tree decl) /* If this entity was used, let the back end see it; it will decide whether or not to emit it into the object file. */ if (TREE_USED (decl)) - return true; + return true; + /* Virtual functions might be needed for devirtualization. */ if (flag_devirtualize && TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl)) return true; + /* Otherwise, DECL does not need to be emitted -- yet. A subsequent reference to DECL might cause it to be emitted later. */ return false; @@ -4803,7 +4805,6 @@ c_parse_final_cleanups (void) perform_deferred_noexcept_checks (); finish_repo (); - fini_constexpr (); /* The entire file is now complete. If requested, dump everything Index: method.c =================================================================== --- method.c (revision 249779) +++ method.c (working copy) @@ -1982,7 +1982,6 @@ implicitly_declare_fn (special_function_ case sfk_move_assignment: case sfk_inheriting_constructor: { - bool move_p; if (kind == sfk_copy_assignment || kind == sfk_move_assignment) { @@ -2000,8 +1999,8 @@ implicitly_declare_fn (special_function_ rhs_parm_type = cp_build_qualified_type (type, TYPE_QUAL_CONST); else rhs_parm_type = type; - move_p = (kind == sfk_move_assignment - || kind == sfk_move_constructor); + bool move_p = (kind == sfk_move_assignment + || kind == sfk_move_constructor); rhs_parm_type = cp_build_reference_type (rhs_parm_type, move_p); parameter_types = tree_cons (NULL_TREE, rhs_parm_type, parameter_types); Index: search.c =================================================================== --- search.c (revision 249779) +++ search.c (working copy) @@ -507,10 +507,13 @@ current_scope (void) && same_type_p (DECL_FRIEND_CONTEXT (current_function_decl), current_class_type)))) return current_function_decl; + if (current_class_type) return current_class_type; + if (current_function_decl) return current_function_decl; + return current_namespace; } g1