From patchwork Thu Oct 3 15:19:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1171252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510156-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cpUoe3nL"; dkim-atps=neutral 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 46kcBT2tXrz9sCJ for ; Fri, 4 Oct 2019 01:20:01 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=B7lfdST0szMY1IBzgKUrmFyv6lFVCCEM0p90KU+mm8AIiwYGdoezL qAeS1UwRyM62rCHMj291IPaNcv+886JCtYpvuymgFRyRi7JVh7ouaiQA52Hg93zO NQjwEs8DRtmoVwnIdEzKnGHNOscNWcVAn93OIcufO4pg1uo3bzoVEo= 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:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=09eUNZ3Tf2wU0THMGc5UM8CuruU=; b=cpUoe3nLu+JFcrzanggE AbkF7/HKyZtM3csyjbv8G7OEIKdfqOt/Eg4wfBLK7SSfbbgCqVzU1GbIpZC0I+zU 9+hc/9o38G/vqoJ8rcA7r/8GjxsBoD1rtbq9S5e1ouvRiNurbf8Wbc0SB7LbDKe+ 7Dc0+ZDrxuPF/33uk/oQeRg= Received: (qmail 62350 invoked by alias); 3 Oct 2019 15:19:33 -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 62281 invoked by uid 89); 3 Oct 2019 15:19:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:PRECEDE, sk:precede, sk:require X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-oln040092071075.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.92.71.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Oct 2019 15:19:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hQ09WJfzairWXF14WhE38nyqLSv52/mhRy9oAoCrb8UD6mA4orB0aK9Ks2ygvL2w6ZyrGGSgRuSzF/+XUOjWHaZJgdZX24P5P2XdqP7jkADMV9hspjEe/e+lFd2v6fZvfbt1U29sn70zHC6oOJiHHAta2OlEk5zg7AsoJi8UPnF23oBkII9/+IbFcwfrgSrHlDAHK5dL3lSDp1598b8OFnEbyt1VnjSofwUfCeqTIBGlwrIf28CbsVHx/7wUXB5bfG39RFFXk3RH30D0PZ4ODSXA4+TGaZLF0T+dPB5NsX9QP7OoDgt8Lkha+H0lsafPcocIbie5kc4RcfgTI4wl5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4d2i/Ea2+RgQSJtMS/DIgVSw14sbbajzjQX6MvD0w6I=; b=AIyt3kP4E03h/q5sBFUU2jxCmWV9Z/8Umq2VBxc2pQw8o00wSOlhwXclVa99sgwLaAHRi9dBvJkvD2dwFx+e1VoPs8UZfL3xn1barCu6W7W1wsKUrJ+frPmVHpsH5MAWmvDFA36YmWh8qytoTLz/oyP32ulkCs//ToV11dAlZ/dmPAZB5Q9nDvS01ql5vUogsjZBUgahB9MwMHy0Qj3YOJn9GoMsFyoMtD4D1hzxDbjjANjmIH9r1I5N/6Wt/hsCVdgxD334E3FIXfZ3Sw9Dhh8XQ0PlfFHKr+TmO11JfJx6JxkCj8S1PiMZBhDO1aW1PpI2IZDfZ4r6bbsmQt1qSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com (10.152.16.56) by AM5EUR03HT238.eop-EUR03.prod.protection.outlook.com (10.152.17.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15; Thu, 3 Oct 2019 15:19:26 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com (10.152.16.58) by AM5EUR03FT057.mail.protection.outlook.com (10.152.17.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Thu, 3 Oct 2019 15:19:26 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::1917:2b45:72b0:548a]) by VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::1917:2b45:72b0:548a%7]) with mapi id 15.20.2305.023; Thu, 3 Oct 2019 15:19:26 +0000 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , Ian Lance Taylor Subject: [PATCH, GO] Fix -Wshadow=local in go frontend Date: Thu, 3 Oct 2019 15:19:26 +0000 Message-ID: x-microsoft-original-message-id: <00ed575f-78bd-13d0-f5bc-aecc407a70e7@hotmail.de> x-ms-exchange-transport-forked: True MIME-Version: 1.0 Hi, this would normally be a trivial changes, but unless I am mistaken, I cannot simply commit to the go subtree. Except the -Wshadow=local warnings this fixes also a few minor memory leaks. Bootstrapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Ian, can you please commit this on my behalf? Thanks Bernd. 2019-10-03 Bernd Edlinger * gofrontend/ast-dump.cc (Ast_dump_traverse_blocks_and_functions::function): Remove shadowing local var. * gofrontend/escape.cc (Escape_analysis_assign::expression): Likewise. * gofrontend/expressions.cc (Type_conversion_expression::do_get_backend): Rename local var. Add missing free. (Bound_method_expression::do_flatten): Rename local var. (Builtin_call_expression::lower_make, Builtin_call_expression::flatten_append): Remove shadowing local vars. (Call_expression::do_lower): Rename local vars. (Call_expression::do_get_backend): Remove shadowing local var. (Call_expression::lower_array, Interface_info_expression::do_type): Rename local var. * gofrontend/gogo.cc (Gogo::import_package, Gogo::define_global_names, Gogo::recompute_init_priorities): Rename local var. (Function::build): Remove shadowing local var. Rename local var. * gofrontend/parse.cc (Parse::parameter_list, Parse::composite_lit): Rename local var. * gofrontend/statements.cc (Thunk_statement::build_thunk, Select_statement::lower_two_case, For_range_statement::lower_range_array, For_range_statement::lower_range_slice): Remove shadowing local vars. (For_range_statement::lower_array_range_clear): Rename local var. * gofrontend/types.cc (Struct_type::do_type_descriptor): Remove shadowing local vars. (Struct_type::do_reflection): Rename local var. (Array_type::verify_length): Rename local var. Add missing mpz_clear. (Array_type::do_export): Add missing free. (Interface_type::do_import): Rename local var. Index: gcc/go/gofrontend/ast-dump.cc =================================================================== --- gcc/go/gofrontend/ast-dump.cc (revision 276484) +++ gcc/go/gofrontend/ast-dump.cc (working copy) @@ -135,7 +135,7 @@ Ast_dump_traverse_blocks_and_functions::function(N { if (it != res->begin()) this->ast_dump_context_->ostream() << ","; - Named_object* no = (*it); + no = (*it); this->ast_dump_context_->ostream() << no->name() << " "; go_assert(no->is_result_variable()); Index: gcc/go/gofrontend/escape.cc =================================================================== --- gcc/go/gofrontend/escape.cc (revision 276484) +++ gcc/go/gofrontend/escape.cc (working copy) @@ -1541,7 +1541,6 @@ Escape_analysis_assign::expression(Expression** pe if (debug_level > 1) { - Node* n = Node::make_node(*pexpr); std::string fn_name = this->context_->current_function_name(); go_debug((*pexpr)->location(), "[%d] %s esc: %s", this->context_->loop_depth(), fn_name.c_str(), Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 276484) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -4104,9 +4104,11 @@ Type_conversion_expression::do_get_backend(Transla x = mpz_get_ui(intval); else { - char* s = mpz_get_str(NULL, 16, intval); + char* s1 = mpz_get_str(NULL, 16, intval); go_warning_at(loc, 0, - "unicode code point 0x%s out of range in string", s); + "unicode code point 0x%s out of range in string", + s1); + free(s1); x = 0xfffd; } Lex::append_char(x, true, &s, loc); @@ -8038,13 +8040,13 @@ Bound_method_expression::do_flatten(Gogo* gogo, Na if (this->method_->is_value_method() && expr->type()->points_to() != NULL) { - Expression* n = Expression::make_binary(OPERATOR_EQEQ, expr, - Expression::make_nil(loc), - loc); + Expression* n1 = Expression::make_binary(OPERATOR_EQEQ, expr, + Expression::make_nil(loc), + loc); if (nil_check == NULL) - nil_check = n; + nil_check = n1; else - nil_check = Expression::make_binary(OPERATOR_OROR, nil_check, n, loc); + nil_check = Expression::make_binary(OPERATOR_OROR, nil_check, n1, loc); } if (nil_check != NULL) @@ -8741,8 +8743,6 @@ Builtin_call_expression::lower_make(Statement_inse Expression::make_nil(loc)); else { - Numeric_constant nclen; - unsigned long vlen; if (len_arg->numeric_constant_value(&nclen) && nclen.to_unsigned_long(&vlen) == Numeric_constant::NC_UL_VALID && vlen <= Map_type::bucket_size) @@ -9053,8 +9053,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo else { Type* int32_type = Type::lookup_integer_type("int32"); - Expression* zero = - Expression::make_integer_ul(0, int32_type, loc); + zero = Expression::make_integer_ul(0, int32_type, loc); call = Runtime::make_call(Runtime::BUILTIN_MEMSET, loc, 3, a1, zero, a2); } @@ -9064,15 +9063,12 @@ Builtin_call_expression::flatten_append(Gogo* gogo // For a slice containing pointers, growslice already zeroed // the memory. We only need to zero in non-growing case. // Note: growslice does not zero the memory in non-pointer case. - Expression* left = - Expression::make_temporary_reference(ntmp, loc); + left = Expression::make_temporary_reference(ntmp, loc); left = Expression::make_cast(uint_type, left, loc); - Expression* right = - Expression::make_temporary_reference(c1tmp, loc); + right = Expression::make_temporary_reference(c1tmp, loc); right = Expression::make_cast(uint_type, right, loc); - Expression* cond = - Expression::make_binary(OPERATOR_GT, left, right, loc); - Expression* zero = Expression::make_integer_ul(0, int_type, loc); + cond = Expression::make_binary(OPERATOR_GT, left, right, loc); + zero = Expression::make_integer_ul(0, int_type, loc); call = Expression::make_conditional(cond, call, zero, loc); } } @@ -10877,9 +10873,9 @@ Call_expression::do_lower(Gogo* gogo, Named_object if (this->result_count() > 1 && this->call_temp_ == NULL) { Struct_field_list* sfl = new Struct_field_list(); - Function_type* fntype = this->get_function_type(); - const Typed_identifier_list* results = fntype->results(); - Location loc = this->location(); + Function_type* fntype1 = this->get_function_type(); + const Typed_identifier_list* results = fntype1->results(); + Location loc0 = this->location(); int i = 0; char buf[20]; @@ -10888,12 +10884,12 @@ Call_expression::do_lower(Gogo* gogo, Named_object ++p, ++i) { snprintf(buf, sizeof buf, "res%d", i); - sfl->push_back(Struct_field(Typed_identifier(buf, p->type(), loc))); + sfl->push_back(Struct_field(Typed_identifier(buf, p->type(), loc0))); } - Struct_type* st = Type::make_struct_type(sfl, loc); + Struct_type* st = Type::make_struct_type(sfl, loc0); st->set_is_struct_incomparable(); - this->call_temp_ = Statement::make_temporary(st, NULL, loc); + this->call_temp_ = Statement::make_temporary(st, NULL, loc0); inserter->insert(this->call_temp_); } @@ -12295,7 +12291,6 @@ Call_expression::do_get_backend(Translate_context* } else { - Expression* first_arg; fn = this->interface_method_function(interface_method, &first_arg, location); fn_args[0] = first_arg->get_backend(context); @@ -16453,11 +16448,11 @@ Composite_literal_expression::lower_array(Type* ty traverse_order = new std::vector(); traverse_order->reserve(v.size()); - for (V::const_iterator p = v.begin(); p != v.end(); ++p) + for (V::const_iterator p1 = v.begin(); p1 != v.end(); ++p1) { - indexes->push_back(p->index); - vals->push_back(p->expr); - traverse_order->push_back(p->traversal_order); + indexes->push_back(p1->index); + vals->push_back(p1->expr); + traverse_order->push_back(p1->traversal_order); } } @@ -17771,9 +17766,9 @@ Interface_info_expression::do_type() Interface_type* itype = this->iface_->type()->interface_type(); - Hashtable::const_iterator p = result_types.find(itype); - if (p != result_types.end()) - return p->second; + Hashtable::const_iterator p1 = result_types.find(itype); + if (p1 != result_types.end()) + return p1->second; Type* pdt = Type::make_type_descriptor_ptr_type(); if (itype->is_empty()) Index: gcc/go/gofrontend/gogo.cc =================================================================== --- gcc/go/gofrontend/gogo.cc (revision 276484) +++ gcc/go/gofrontend/gogo.cc (working copy) @@ -518,11 +518,11 @@ Gogo::import_package(const std::string& filename, else if (ln == ".") { Bindings* bindings = package->bindings(); - for (Bindings::const_declarations_iterator p = + for (Bindings::const_declarations_iterator p1 = bindings->begin_declarations(); - p != bindings->end_declarations(); - ++p) - this->add_dot_import_object(p->second); + p1 != bindings->end_declarations(); + ++p1) + this->add_dot_import_object(p1->second); std::string dot_alias = "." + package->package_name(); package->add_alias(dot_alias, location); } @@ -678,8 +678,8 @@ Gogo::recompute_init_priorities() pci != ii->precursors().end(); ++pci) { - Import_init* ii = this->lookup_init(*pci); - nonroots.insert(ii); + Import_init* ii1 = this->lookup_init(*pci); + nonroots.insert(ii1); } } @@ -2613,11 +2613,11 @@ Gogo::define_global_names() { if (no->type_declaration_value()->has_methods()) { - for (std::vector::const_iterator p = + for (std::vector::const_iterator p1 = no->type_declaration_value()->methods()->begin(); - p != no->type_declaration_value()->methods()->end(); - p++) - go_error_at((*p)->location(), + p1 != no->type_declaration_value()->methods()->end(); + p1++) + go_error_at((*p1)->location(), "may not define methods on non-local type"); } no->set_type_value(global_no->type_value()); @@ -6550,7 +6550,6 @@ Function::build(Gogo* gogo, Named_object* named_fu // Build the backend representation for all the statements in the // function. - Translate_context context(gogo, named_function, NULL, NULL); Bblock* code_block = this->block_->get_backend(&context); // Initialize variables if necessary. @@ -6608,8 +6607,8 @@ Function::build(Gogo* gogo, Named_object* named_fu // If we created a descriptor for the function, make sure we emit it. if (this->descriptor_ != NULL) { - Translate_context context(gogo, NULL, NULL, NULL); - this->descriptor_->get_backend(&context); + Translate_context context1(gogo, NULL, NULL, NULL); + this->descriptor_->get_backend(&context1); } } Index: gcc/go/gofrontend/parse.cc =================================================================== --- gcc/go/gofrontend/parse.cc (revision 276484) +++ gcc/go/gofrontend/parse.cc (working copy) @@ -815,7 +815,7 @@ Parse::parameters(Typed_identifier_list** pparams, Typed_identifier_list* Parse::parameter_list(bool* is_varargs) { - Location location = this->location(); + Location location1 = this->location(); Typed_identifier_list* ret = new Typed_identifier_list(); bool saw_error = false; @@ -995,7 +995,7 @@ Parse::parameter_list(bool* is_varargs) } if (mix_error) { - go_error_at(location, "invalid named/anonymous mix"); + go_error_at(location1, "invalid named/anonymous mix"); saw_error = true; } if (saw_error) @@ -2808,7 +2808,7 @@ Parse::composite_lit(Type* type, int depth, Locati { std::string identifier = token->identifier(); bool is_exported = token->is_identifier_exported(); - Location location = token->location(); + Location location1 = token->location(); if (this->advance_token()->is_op(OPERATOR_COLON)) { @@ -2820,7 +2820,7 @@ Parse::composite_lit(Type* type, int depth, Locati Gogo* gogo = this->gogo_; val = this->id_to_expression(gogo->pack_hidden_name(identifier, is_exported), - location, false); + location1, false); is_name = true; } else @@ -2827,7 +2827,7 @@ Parse::composite_lit(Type* type, int depth, Locati { this->unget_token(Token::make_identifier_token(identifier, is_exported, - location)); + location1)); val = this->expression(PRECEDENCE_NORMAL, false, true, NULL, NULL); } @@ -2923,14 +2923,14 @@ Parse::composite_lit(Type* type, int depth, Locati go_error_at(this->location(), "expected %<,%> or %<}%>"); this->gogo_->mark_locals_used(); - int depth = 0; + int depth1 = 0; while (!token->is_eof() - && (depth > 0 || !token->is_op(OPERATOR_RCURLY))) + && (depth1 > 0 || !token->is_op(OPERATOR_RCURLY))) { if (token->is_op(OPERATOR_LCURLY)) - ++depth; + ++depth1; else if (token->is_op(OPERATOR_RCURLY)) - --depth; + --depth1; token = this->advance_token(); } if (token->is_op(OPERATOR_RCURLY)) Index: gcc/go/gofrontend/statements.cc =================================================================== --- gcc/go/gofrontend/statements.cc (revision 276484) +++ gcc/go/gofrontend/statements.cc (working copy) @@ -2938,7 +2938,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std go_assert(call_statement->classification() == STATEMENT_EXPRESSION); Expression_statement* es = static_cast(call_statement); - Call_expression* ce = es->expr()->call_expression(); + ce = es->expr()->call_expression(); if (ce == NULL) go_assert(saw_errors()); else @@ -5972,7 +5972,7 @@ Select_statement::lower_two_case(Block* b) // if selectnbrecv2(&lhs, &ok, chan) { body } else { default body } Type* booltype = Type::make_boolean_type(); - Temporary_statement* ts = Statement::make_temporary(booltype, NULL, loc); + ts = Statement::make_temporary(booltype, NULL, loc); b->add_statement(ts); okref = Expression::make_temporary_reference(ts, loc); @@ -6595,7 +6595,7 @@ For_range_statement::lower_range_array(Gogo* gogo, iter_init = new Block(body_block, loc); ref = Expression::make_temporary_reference(range_temp, loc); - Expression* ref2 = Expression::make_temporary_reference(index_temp, loc); + ref2 = Expression::make_temporary_reference(index_temp, loc); Expression* index = Expression::make_index(ref, ref2, NULL, NULL, loc); tref = Expression::make_temporary_reference(value_temp, loc); @@ -6693,7 +6693,7 @@ For_range_statement::lower_range_slice(Gogo* gogo, iter_init = new Block(body_block, loc); ref = Expression::make_temporary_reference(for_temp, loc); - Expression* ref2 = Expression::make_temporary_reference(index_temp, loc); + ref2 = Expression::make_temporary_reference(index_temp, loc); Expression* index = Expression::make_index(ref, ref2, NULL, NULL, loc); tref = Expression::make_temporary_reference(value_temp, loc); @@ -7179,9 +7179,9 @@ For_range_statement::lower_array_range_clear(Gogo* else { Type* int32_type = Type::lookup_integer_type("int32"); - Expression* zero = Expression::make_integer_ul(0, int32_type, loc); + Expression* zero1 = Expression::make_integer_ul(0, int32_type, loc); call = Runtime::make_call(Runtime::BUILTIN_MEMSET, loc, 3, ptr_arg, - zero, sz_arg); + zero1, sz_arg); } Statement* cs3 = Statement::make_statement(call, true); b->add_statement(cs3); Index: gcc/go/gofrontend/types.cc =================================================================== --- gcc/go/gofrontend/types.cc (revision 276484) +++ gcc/go/gofrontend/types.cc (working copy) @@ -6410,12 +6410,11 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_ fvals->push_back(Expression::make_nil(bloc)); else { - std::string n; if (is_embedded_builtin) n = gogo->package_name(); else n = Gogo::hidden_name_pkgpath(pf->field_name()); - Expression* s = Expression::make_string(n, bloc); + s = Expression::make_string(n, bloc); fvals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); } @@ -6429,7 +6428,7 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_ fvals->push_back(Expression::make_nil(bloc)); else { - Expression* s = Expression::make_string(pf->tag(), bloc); + s = Expression::make_string(pf->tag(), bloc); fvals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); } @@ -6635,22 +6634,22 @@ Struct_type::do_reflection(Gogo* gogo, std::string { const std::string& tag(p->tag()); ret->append(" \""); - for (std::string::const_iterator p = tag.begin(); - p != tag.end(); - ++p) + for (std::string::const_iterator q = tag.begin(); + q != tag.end(); + ++q) { - if (*p == '\0') + if (*q == '\0') ret->append("\\x00"); - else if (*p == '\n') + else if (*q == '\n') ret->append("\\n"); - else if (*p == '\t') + else if (*q == '\t') ret->append("\\t"); - else if (*p == '"') + else if (*q == '"') ret->append("\\\""); - else if (*p == '\\') + else if (*q == '\\') ret->append("\\\\"); else - ret->push_back(*p); + ret->push_back(*q); } ret->push_back('"'); } @@ -7197,11 +7196,11 @@ Array_type::verify_length() return false; case Numeric_constant::NC_UL_BIG: { - mpz_t val; - if (!nc.to_int(&val)) + mpz_t val1; + if (!nc.to_int(&val1)) go_unreachable(); - unsigned int bits = mpz_sizeinbase(val, 2); - mpz_clear(val); + unsigned int bits = mpz_sizeinbase(val1, 2); + mpz_clear(val1); if (bits >= tbits) { go_error_at(this->length_->location(), "array bound overflows"); @@ -7705,6 +7704,7 @@ Array_type::do_export(Export* exp) const char* s = mpz_get_str(NULL, 10, val); exp->write_string(s); exp->write_string(" "); + free(s); mpz_clear(val); } exp->write_c_string("] "); @@ -9730,9 +9730,9 @@ Interface_type::do_import(Import* imp) Typed_identifier_list* methods = new Typed_identifier_list; while (imp->peek_char() != '}') { - std::string name = imp->read_identifier(); + std::string name1 = imp->read_identifier(); - if (name == "?") + if (name1 == "?") { imp->require_c_string(" "); Type* t = imp->read_type(); @@ -9809,7 +9809,7 @@ Interface_type::do_import(Import* imp) imp->location()); if (is_varargs) fntype->set_is_varargs(); - methods->push_back(Typed_identifier(name, fntype, imp->location())); + methods->push_back(Typed_identifier(name1, fntype, imp->location())); imp->require_c_string("; "); }