Also add a couple of missing calls to free after mpz_get_str.
This should make the code clean with respect to -Wshadow=local.
Based on patch by Bernd Edlinger.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198837
From-SVN: r276579
-a3aef6b6df932ea6c7094d074695bc0b033a3d17
+441f3f1f350b532707c48273d7f454cf1c4e959f
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
{
if (it != res->begin())
this->ast_dump_context_->ostream() << ",";
- Named_object* no = (*it);
+ Named_object* rno = (*it);
- this->ast_dump_context_->ostream() << no->name() << " ";
- go_assert(no->is_result_variable());
- Result_variable* resvar = no->result_var_value();
+ this->ast_dump_context_->ostream() << rno->name() << " ";
+ go_assert(rno->is_result_variable());
+ Result_variable* resvar = rno->result_var_value();
this->ast_dump_context_->dump_type(resvar->type());
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(),
x = mpz_get_ui(intval);
else
{
- char* s = mpz_get_str(NULL, 16, intval);
+ char* ms = 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",
+ ms);
+ free(ms);
x = 0xfffd;
}
Lex::append_char(x, true, &s, loc);
Expression* ret = Expression::make_struct_composite_literal(st, vals, loc);
ret = Expression::make_heap_expression(ret, loc);
- Node* n = Node::make_node(this);
- if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
+ Node* node = Node::make_node(this);
+ if ((node->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
ret->heap_expression()->set_allocate_on_stack();
else if (gogo->compiling_runtime()
&& gogo->package_name() == "runtime"
&& !saw_errors())
go_error_at(loc, "%s escapes to heap, not allowed in runtime",
- n->ast_format(gogo).c_str());
+ node->ast_format(gogo).c_str());
// If necessary, check whether the expression or any embedded
// pointers are nil.
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)
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);
}
// 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_cast(uint_type, left, loc);
- Expression* 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);
+ ref = Expression::make_temporary_reference(ntmp, loc);
+ ref = Expression::make_cast(uint_type, ref, loc);
+ ref2 = Expression::make_temporary_reference(c1tmp, loc);
+ ref2 = Expression::make_cast(uint_type, ref2, loc);
+ cond = Expression::make_binary(OPERATOR_GT, ref, ref2, loc);
+ zero = Expression::make_integer_ul(0, int_type, loc);
call = Expression::make_conditional(cond, call, zero, loc);
}
}
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();
int i = 0;
char buf[20];
}
else
{
- Expression* first_arg;
- fn = this->interface_method_function(interface_method, &first_arg,
+ Expression* arg0;
+ fn = this->interface_method_function(interface_method, &arg0,
location);
- fn_args[0] = first_arg->get_backend(context);
+ fn_args[0] = arg0->get_backend(context);
}
Bexpression* bclosure = NULL;
traverse_order = new std::vector<unsigned long>();
traverse_order->reserve(v.size());
- for (V::const_iterator p = v.begin(); p != v.end(); ++p)
+ for (V::const_iterator pv = v.begin(); pv != v.end(); ++pv)
{
- indexes->push_back(p->index);
- vals->push_back(p->expr);
- traverse_order->push_back(p->traversal_order);
+ indexes->push_back(pv->index);
+ vals->push_back(pv->expr);
+ traverse_order->push_back(pv->traversal_order);
}
}
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 pr = result_types.find(itype);
+ if (pr != result_types.end())
+ return pr->second;
Type* pdt = Type::make_type_descriptor_ptr_type();
if (itype->is_empty())
else if (ln == ".")
{
Bindings* bindings = package->bindings();
- for (Bindings::const_declarations_iterator p =
+ for (Bindings::const_declarations_iterator pd =
bindings->begin_declarations();
- p != bindings->end_declarations();
- ++p)
- this->add_dot_import_object(p->second);
+ pd != bindings->end_declarations();
+ ++pd)
+ this->add_dot_import_object(pd->second);
std::string dot_alias = "." + package->package_name();
package->add_alias(dot_alias, location);
}
pci != ii->precursors().end();
++pci)
{
- Import_init* ii = this->lookup_init(*pci);
- nonroots.insert(ii);
+ Import_init* ii_init = this->lookup_init(*pci);
+ nonroots.insert(ii_init);
}
}
{
if (no->type_declaration_value()->has_methods())
{
- for (std::vector<Named_object*>::const_iterator p =
+ for (std::vector<Named_object*>::const_iterator pm =
no->type_declaration_value()->methods()->begin();
- p != no->type_declaration_value()->methods()->end();
- p++)
- go_error_at((*p)->location(),
+ pm != no->type_declaration_value()->methods()->end();
+ pm++)
+ go_error_at((*pm)->location(),
"may not define methods on non-local type");
}
no->set_type_value(global_no->type_value());
// 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);
+ Translate_context bcontext(gogo, named_function, NULL, NULL);
+ Bblock* code_block = this->block_->get_backend(&bcontext);
// Initialize variables if necessary.
Translate_context icontext(gogo, named_function, this->block_,
// 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 dcontext(gogo, NULL, NULL, NULL);
+ this->descriptor_->get_backend(&dcontext);
}
}
{
std::string name = token->identifier();
bool is_exported = token->is_identifier_exported();
- Location location = token->location();
+ Location id_location = token->location();
token = this->advance_token();
if (!token->is_op(OPERATOR_COMMA))
{
}
this->unget_token(Token::make_identifier_token(name, is_exported,
- location));
+ id_location));
}
else
{
// commas as we can.
std::string id_name = this->gogo_->pack_hidden_name(name,
is_exported);
- ret->push_back(Typed_identifier(id_name, NULL, location));
+ ret->push_back(Typed_identifier(id_name, NULL, id_location));
bool just_saw_comma = true;
while (this->advance_token()->is_identifier())
{
name = this->peek_token()->identifier();
is_exported = this->peek_token()->is_identifier_exported();
- location = this->peek_token()->location();
+ id_location = this->peek_token()->location();
id_name = this->gogo_->pack_hidden_name(name, is_exported);
- ret->push_back(Typed_identifier(id_name, NULL, location));
+ ret->push_back(Typed_identifier(id_name, NULL, id_location));
if (!this->advance_token()->is_op(OPERATOR_COMMA))
{
just_saw_comma = false;
// names.
parameters_have_names = false;
this->unget_token(Token::make_identifier_token(name, is_exported,
- location));
+ id_location));
ret->pop_back();
just_saw_comma = true;
}
{
std::string identifier = token->identifier();
bool is_exported = token->is_identifier_exported();
- Location location = token->location();
+ Location id_location = token->location();
if (this->advance_token()->is_op(OPERATOR_COLON))
{
Gogo* gogo = this->gogo_;
val = this->id_to_expression(gogo->pack_hidden_name(identifier,
is_exported),
- location, false);
+ id_location, false);
is_name = true;
}
else
{
this->unget_token(Token::make_identifier_token(identifier,
is_exported,
- location));
+ id_location));
val = this->expression(PRECEDENCE_NORMAL, false, true, NULL,
NULL);
}
go_error_at(this->location(), "expected %<,%> or %<}%>");
this->gogo_->mark_locals_used();
- int depth = 0;
+ int edepth = 0;
while (!token->is_eof()
- && (depth > 0 || !token->is_op(OPERATOR_RCURLY)))
+ && (edepth > 0 || !token->is_op(OPERATOR_RCURLY)))
{
if (token->is_op(OPERATOR_LCURLY))
- ++depth;
+ ++edepth;
else if (token->is_op(OPERATOR_RCURLY))
- --depth;
+ --edepth;
token = this->advance_token();
}
if (token->is_op(OPERATOR_RCURLY))
go_assert(call_statement->classification() == STATEMENT_EXPRESSION);
Expression_statement* es =
static_cast<Expression_statement*>(call_statement);
- Call_expression* ce = es->expr()->call_expression();
+ ce = es->expr()->call_expression();
if (ce == NULL)
go_assert(saw_errors());
else
// if selectnbrecv2(&lhs, &ok, chan) { body } else { default body }
Type* booltype = Type::make_boolean_type();
- Temporary_statement* ts = Statement::make_temporary(booltype, NULL, loc);
- b->add_statement(ts);
+ Temporary_statement* okts = Statement::make_temporary(booltype, NULL,
+ loc);
+ b->add_statement(okts);
- okref = Expression::make_temporary_reference(ts, loc);
+ okref = Expression::make_temporary_reference(okts, loc);
Expression* okaddr = Expression::make_unary(OPERATOR_AND, okref, loc);
call = Runtime::make_call(Runtime::SELECTNBRECV2, loc, 3, addr, okaddr,
chanref);
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);
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);
else
{
Type* int32_type = Type::lookup_integer_type("int32");
- Expression* zero = Expression::make_integer_ul(0, int32_type, loc);
+ Expression* zero32 = Expression::make_integer_ul(0, int32_type, loc);
call = Runtime::make_call(Runtime::BUILTIN_MEMSET, loc, 3, ptr_arg,
- zero, sz_arg);
+ zero32, sz_arg);
}
Statement* cs3 = Statement::make_statement(call, true);
b->add_statement(cs3);
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));
}
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));
}
{
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 pt = tag.begin();
+ pt != tag.end();
+ ++pt)
{
- if (*p == '\0')
+ if (*pt == '\0')
ret->append("\\x00");
- else if (*p == '\n')
+ else if (*pt == '\n')
ret->append("\\n");
- else if (*p == '\t')
+ else if (*pt == '\t')
ret->append("\\t");
- else if (*p == '"')
+ else if (*pt == '"')
ret->append("\\\"");
- else if (*p == '\\')
+ else if (*pt == '\\')
ret->append("\\\\");
else
- ret->push_back(*p);
+ ret->push_back(*pt);
}
ret->push_back('"');
}
return false;
case Numeric_constant::NC_UL_BIG:
{
- mpz_t val;
- if (!nc.to_int(&val))
+ mpz_t mval;
+ if (!nc.to_int(&mval))
go_unreachable();
- unsigned int bits = mpz_sizeinbase(val, 2);
- mpz_clear(val);
+ unsigned int bits = mpz_sizeinbase(mval, 2);
+ mpz_clear(mval);
if (bits >= tbits)
{
go_error_at(this->length_->location(), "array bound overflows");
}
char* s = mpz_get_str(NULL, 10, val);
exp->write_string(s);
+ free(s);
exp->write_string(" ");
mpz_clear(val);
}
parameters = new Typed_identifier_list;
while (true)
{
- std::string name = imp->read_name();
+ std::string pname = imp->read_name();
imp->require_c_string(" ");
if (imp->match_c_string("..."))
Type* ptype = imp->read_type();
if (is_varargs)
ptype = Type::make_array_type(ptype, NULL);
- parameters->push_back(Typed_identifier(name, ptype,
+ parameters->push_back(Typed_identifier(pname, ptype,
imp->location()));
if (imp->peek_char() != ',')
break;
imp->advance(1);
while (true)
{
- std::string name = imp->read_name();
+ std::string rname = imp->read_name();
imp->require_c_string(" ");
Type* rtype = imp->read_type();
- results->push_back(Typed_identifier(name, rtype,
+ results->push_back(Typed_identifier(rname, rtype,
imp->location()));
if (imp->peek_char() != ',')
break;