From patchwork Wed Dec 21 08:05:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 35290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3397402wrn; Wed, 21 Dec 2022 00:06:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVwedmh9oQ9aAn9aYkG6V8dfNy9G5HHm1l3izNb5GW0pKl62J1bo+Ivuqe5/u3BAusMA2+ X-Received: by 2002:a17:906:184a:b0:78d:f456:1ed0 with SMTP id w10-20020a170906184a00b0078df4561ed0mr4642133eje.33.1671610003394; Wed, 21 Dec 2022 00:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671610003; cv=none; d=google.com; s=arc-20160816; b=lP7f3/+iwpvtb58y1ENKkSADjdFD9LGJQEti7t1MhKe1XMFRk6R/7q23Fxui0UUCyi y3hAGmFrzB/D9v27AaWqiAS/+AZcxMychhNIaM50B/+ANlzTvTgUsphW+THSX/X6GcJj v4gBjcWgIE7JcKF4KGbSlmowaveQR14MIcKew/jU/yrhkEDoy0QT54RZQqlTDPzucyQD 5NmDi2sjSItQxJvNSGQnlmEVx6PIhDQWJ0qBRdXsczsrWsjq4bYYryAUs7yQF++V3bg7 jG9LJ10eFcxS5f8K1itf8oknsXmNfAbHp/OOU0wAc0pEZF/F+ahcjhWoZi8pknODfTR+ 6XfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=jibbDBphHWXonb0hBXhNy/3U2wu122Y+41luQ1H7OB0=; b=XtWwYN3SmPUMmZ9TN0rKewTGi/gD5t1S896pqaLWNRd2BTqDACZTvKvaVxic49Z2Us XbCqcU1fZiUz+1hu4HRHRDHGWAdt/T0lVX3z12/T6ONf4YKQRLimlbZb2V/hekRPpzDE FP37A58+FZSDClUlXaFDK5hW18XrQo2CBnN1ezbtk1T5Fk05uVMLYffQkLvIoWoDHV4z 7Tc1Buc+/do7N5BatGi2WLGgfRt7PY78ABqGtbnR7EZq+zS0Y6Ts3ybp6RQLLC6aF/FP bERRzC/tpDGpZ4Kw8Mvml+7SagWIOdirXa8mG0MTuT0LkwYDEP614maztAkrD6k7V0/8 jpBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rtxpDdOa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gs18-20020a170906f19200b007c0b56b90f5si10605287ejb.307.2022.12.21.00.06.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 00:06:43 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rtxpDdOa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55C123845846 for ; Wed, 21 Dec 2022 08:06:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 96C1D384F030 for ; Wed, 21 Dec 2022 08:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96C1D384F030 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 88EAA4FDA; Wed, 21 Dec 2022 08:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1671609942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jibbDBphHWXonb0hBXhNy/3U2wu122Y+41luQ1H7OB0=; b=rtxpDdOaW2xfel8b3uceOMc/cZsIuHgIw5D/bUlNJBi4dwx5ILpcD97jxW67CWUHCZde6e tKv/9+ukchGdlZsAYjJb739hQixATkndDIbc8Z6KGB2jqWUncd2H3VyWW1MPK/PO2+U9uL QPk/gfpLO6B1miIwwsSu2ouBFW1wHXk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1671609942; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jibbDBphHWXonb0hBXhNy/3U2wu122Y+41luQ1H7OB0=; b=4KntCk/5iGVrnkd+15OeC0EjWlOJK46BpNSkS+lLyMRscObnrJrdCkQUl0H7/E13Gq0C2b dBpjCr3cvb3K73DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 448BB13913; Wed, 21 Dec 2022 08:05:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EOjuD1a+omP9YgAAMHmgww (envelope-from ); Wed, 21 Dec 2022 08:05:42 +0000 Message-ID: Date: Wed, 21 Dec 2022 09:05:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] go: fix clang warnings To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Ian Lance Taylor X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752810130663076644?= X-GMAIL-MSGID: =?utf-8?q?1752810130663076644?= The patch fixes the following Clang warnings: gcc/go/gofrontend/escape.cc:1290:17: warning: private field 'fn_' is not used [-Wunused-private-field] gcc/go/gofrontend/escape.cc:3478:19: warning: private field 'context_' is not used [-Wunused-private-field] gcc/go/gofrontend/lex.h:564:15: warning: private field 'input_file_name_' is not used [-Wunused-private-field] gcc/go/gofrontend/types.cc:5788:20: warning: private field 'call_' is not used [-Wunused-private-field] gcc/go/gofrontend/wb.cc:206:9: warning: private field 'gogo_' is not used [-Wunused-private-field] Ready for master? Thanks, Martin gcc/go/ChangeLog: * gofrontend/escape.cc (Gogo::analyze_escape): Remove context arg. (Gogo::assign_connectivity): Likewise. (class Escape_analysis_tag): Remove context ctor argument. (Gogo::tag_function): Likewise. * gofrontend/expressions.cc (Call_expression::do_type): Remove extra arg. * gofrontend/gogo.h (class Gogo): Remove context arg. * gofrontend/lex.h (class Lex): Make input_file_name_ with ATTRIBUTE_UNUSED. * gofrontend/types.cc (class Call_multiple_result_type): Remove call_ argument. (Type::make_call_multiple_result_type): Likewise. * gofrontend/types.h (class Type): Remove argument. * gofrontend/wb.cc (class Check_escape): Remove gogo_ field. (Gogo::add_write_barriers): Remove extra arg. --- gcc/go/gofrontend/escape.cc | 20 +++++++------------- gcc/go/gofrontend/expressions.cc | 2 +- gcc/go/gofrontend/gogo.h | 2 +- gcc/go/gofrontend/lex.h | 2 +- gcc/go/gofrontend/types.cc | 13 ++++--------- gcc/go/gofrontend/types.h | 2 +- gcc/go/gofrontend/wb.cc | 10 +++------- 7 files changed, 18 insertions(+), 33 deletions(-) diff --git a/gcc/go/gofrontend/escape.cc b/gcc/go/gofrontend/escape.cc index 6da29edc419..ccbc7910743 100644 --- a/gcc/go/gofrontend/escape.cc +++ b/gcc/go/gofrontend/escape.cc @@ -990,7 +990,7 @@ Gogo::analyze_escape() for (std::vector::iterator fn = stack.begin(); fn != stack.end(); ++fn) - this->tag_function(context, *fn); + this->tag_function(*fn); if (this->debug_escape_level() != 0) { @@ -1246,10 +1246,10 @@ Escape_analysis_loop::statement(Block*, size_t*, Statement* s) class Escape_analysis_assign : public Traverse { public: - Escape_analysis_assign(Escape_context* context, Named_object* fn) + Escape_analysis_assign(Escape_context* context) : Traverse(traverse_statements | traverse_expressions), - context_(context), fn_(fn) + context_(context) { } // Model statements within a function as assignments and flows between nodes. @@ -1286,8 +1286,6 @@ public: private: // The escape context for this set of functions. Escape_context* context_; - // The current function being analyzed. - Named_object* fn_; }; // Helper function to detect self assignment like the following. @@ -2899,7 +2897,7 @@ Gogo::assign_connectivity(Escape_context* context, Named_object* fn) int save_depth = context->loop_depth(); context->set_loop_depth(1); - Escape_analysis_assign ea(context, fn); + Escape_analysis_assign ea(context); Function::Results* res = fn->func_value()->result_variables(); if (res != NULL) { @@ -3465,17 +3463,13 @@ Gogo::propagate_escape(Escape_context* context, Node* dst) class Escape_analysis_tag { public: - Escape_analysis_tag(Escape_context* context) - : context_(context) + Escape_analysis_tag() { } // Add notes to the function's type about the escape information of its // input parameters. void tag(Named_object* fn); - - private: - Escape_context* context_; }; void @@ -3580,9 +3574,9 @@ Escape_analysis_tag::tag(Named_object* fn) // retain analysis results across imports. void -Gogo::tag_function(Escape_context* context, Named_object* fn) +Gogo::tag_function(Named_object* fn) { - Escape_analysis_tag eat(context); + Escape_analysis_tag eat; eat.tag(fn); } diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 71838b14629..53901306ef7 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -12500,7 +12500,7 @@ Call_expression::do_type() else if (results->size() == 1) ret = results->begin()->type(); else - ret = Type::make_call_multiple_result_type(this); + ret = Type::make_call_multiple_result_type(); this->type_ = ret; diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 433fdaebb66..c08a16b74c2 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -879,7 +879,7 @@ class Gogo // Add notes about the escape level of a function's input and output // parameters for exporting and importing top level functions. void - tag_function(Escape_context*, Named_object*); + tag_function(Named_object*); // Reclaim memory of escape analysis Nodes. void diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 1c4cc5bd2a1..701e5d4b353 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -561,7 +561,7 @@ class Lex gather_embed(const char*, const char*); // The input file name. - const char* input_file_name_; + const char* input_file_name_ ATTRIBUTE_UNUSED; // The input file. FILE* input_file_; // The object used to keep track of file names and line numbers. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 9f34801f695..7f471eab428 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -5747,9 +5747,8 @@ Type::make_nil_type() class Call_multiple_result_type : public Type { public: - Call_multiple_result_type(Call_expression* call) - : Type(TYPE_CALL_MULTIPLE_RESULT), - call_(call) + Call_multiple_result_type() + : Type(TYPE_CALL_MULTIPLE_RESULT) { } protected: @@ -5782,18 +5781,14 @@ class Call_multiple_result_type : public Type void do_mangled_name(Gogo*, std::string*, bool*) const { go_assert(saw_errors()); } - - private: - // The expression being called. - Call_expression* call_; }; // Make a call result type. Type* -Type::make_call_multiple_result_type(Call_expression* call) +Type::make_call_multiple_result_type() { - return new Call_multiple_result_type(call); + return new Call_multiple_result_type; } // Class Struct_field. diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index 49404bd6127..057fa014cee 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -535,7 +535,7 @@ class Type make_nil_type(); static Type* - make_call_multiple_result_type(Call_expression*); + make_call_multiple_result_type(); static Struct_type* make_struct_type(Struct_field_list* fields, Location); diff --git a/gcc/go/gofrontend/wb.cc b/gcc/go/gofrontend/wb.cc index 104c5db0b9b..e039c668847 100644 --- a/gcc/go/gofrontend/wb.cc +++ b/gcc/go/gofrontend/wb.cc @@ -191,9 +191,8 @@ Mark_address_taken::expression(Expression** pexpr) class Check_escape : public Traverse { public: - Check_escape(Gogo* gogo) - : Traverse(traverse_expressions | traverse_variables), - gogo_(gogo) + Check_escape() + : Traverse(traverse_expressions | traverse_variables) { } int @@ -201,9 +200,6 @@ class Check_escape : public Traverse int variable(Named_object*); - - private: - Gogo* gogo_; }; int @@ -664,7 +660,7 @@ Gogo::add_write_barriers() { this->propagate_writebarrierrec(); - Check_escape chk(this); + Check_escape chk; this->traverse(&chk); }