Skip to content

Commit 4fbeebe

Browse files
authored
Merge pull request #3361 from tautschnig/vs-shadow-6
Do not shadow source_location [blocks: #2310]
2 parents 582603d + 3fd418f commit 4fbeebe

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/ansi-c/c_typecheck_type.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
345345
exprt f_expr=
346346
static_cast<const exprt &>(type.find(ID_f));
347347

348-
source_locationt source_location=f_expr.find_source_location();
348+
const source_locationt fraction_source_location =
349+
f_expr.find_source_location();
349350

350351
typecheck_expr(f_expr);
351352

@@ -354,14 +355,14 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
354355
mp_integer f_int;
355356
if(to_integer(f_expr, f_int))
356357
{
357-
error().source_location=source_location;
358+
error().source_location = fraction_source_location;
358359
error() << "failed to convert number of fraction bits to constant" << eom;
359360
throw 0;
360361
}
361362

362363
if(f_int<0 || f_int>size_int)
363364
{
364-
error().source_location=source_location;
365+
error().source_location = fraction_source_location;
365366
error() << "fixedbv fraction width invalid" << eom;
366367
throw 0;
367368
}
@@ -376,7 +377,8 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
376377
exprt f_expr=
377378
static_cast<const exprt &>(type.find(ID_f));
378379

379-
source_locationt source_location=f_expr.find_source_location();
380+
const source_locationt fraction_source_location =
381+
f_expr.find_source_location();
380382

381383
typecheck_expr(f_expr);
382384

@@ -385,14 +387,14 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
385387
mp_integer f_int;
386388
if(to_integer(f_expr, f_int))
387389
{
388-
error().source_location=source_location;
390+
error().source_location = fraction_source_location;
389391
error() << "failed to convert number of fraction bits to constant" << eom;
390392
throw 0;
391393
}
392394

393395
if(f_int<1 || f_int+1>=size_int)
394396
{
395-
error().source_location=source_location;
397+
error().source_location = fraction_source_location;
396398
error() << "floatbv fraction width invalid" << eom;
397399
throw 0;
398400
}
@@ -506,7 +508,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type)
506508
void c_typecheck_baset::typecheck_array_type(array_typet &type)
507509
{
508510
exprt &size=type.size();
509-
source_locationt source_location=size.find_source_location();
511+
const source_locationt size_source_location = size.find_source_location();
510512

511513
// check subtype
512514
typecheck_type(type.subtype());
@@ -558,15 +560,15 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
558560
mp_integer s;
559561
if(to_integer(tmp_size, s))
560562
{
561-
error().source_location=source_location;
563+
error().source_location = size_source_location;
562564
error() << "failed to convert constant: "
563565
<< tmp_size.pretty() << eom;
564566
throw 0;
565567
}
566568

567569
if(s<0)
568570
{
569-
error().source_location=source_location;
571+
error().source_location = size_source_location;
570572
error() << "array size must not be negative, "
571573
"but got " << s << eom;
572574
throw 0;
@@ -604,7 +606,6 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
604606
}
605607

606608
// Need to pull out! We insert new symbol.
607-
source_locationt source_location=size.find_source_location();
608609
unsigned count=0;
609610
irep_idt temp_identifier;
610611
std::string suffix;
@@ -626,7 +627,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
626627
new_symbol.type=size.type();
627628
new_symbol.type.set(ID_C_constant, true);
628629
new_symbol.value=size;
629-
new_symbol.location=source_location;
630+
new_symbol.location = size_source_location;
630631
new_symbol.mode = mode;
631632

632633
symbol_table.add(new_symbol);
@@ -637,12 +638,12 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
637638
symbol_expr.type()=new_symbol.type;
638639

639640
code_declt declaration(symbol_expr);
640-
declaration.add_source_location()=source_location;
641+
declaration.add_source_location() = size_source_location;
641642

642643
code_assignt assignment;
643644
assignment.lhs()=symbol_expr;
644645
assignment.rhs()=size;
645-
assignment.add_source_location()=source_location;
646+
assignment.add_source_location() = size_source_location;
646647

647648
// store the code
648649
clean_code.push_back(declaration);

0 commit comments

Comments
 (0)