Skip to content

Commit 0021562

Browse files
authored
Merge pull request #3358 from tautschnig/vs-shadow-9
Do not shadow the class member return_type [blocks: #2310]
2 parents 6dbd02f + b490078 commit 0021562

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,11 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
927927

928928
code_function_callt &fc=to_code_function_call(last);
929929

930-
const auto &return_type = to_code_type(fc.function().type()).return_type();
931-
932930
side_effect_expr_function_callt sideeffect(
933-
fc.function(), fc.arguments(), return_type, fc.source_location());
931+
fc.function(),
932+
fc.arguments(),
933+
to_code_type(fc.function().type()).return_type(),
934+
fc.source_location());
934935

935936
expr.type()=sideeffect.type();
936937

@@ -1987,7 +1988,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
19871988
// This is an undeclared function that's not a builtin.
19881989
// Let's just add it.
19891990
// We do a bit of return-type guessing, but just a bit.
1990-
typet return_type=signed_int_type();
1991+
typet guessed_return_type = signed_int_type();
19911992

19921993
// The following isn't really right and sound, but there
19931994
// are too many idiots out there who use malloc and the like
@@ -1996,14 +1997,16 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
19961997
identifier=="realloc" ||
19971998
identifier=="reallocf" ||
19981999
identifier=="valloc")
1999-
return_type=pointer_type(void_type()); // void *
2000+
{
2001+
guessed_return_type = pointer_type(void_type()); // void *
2002+
}
20002003

20012004
symbolt new_symbol;
20022005

20032006
new_symbol.name=identifier;
20042007
new_symbol.base_name=identifier;
20052008
new_symbol.location=expr.source_location();
2006-
new_symbol.type = code_typet({}, return_type);
2009+
new_symbol.type = code_typet({}, guessed_return_type);
20072010
new_symbol.type.set(ID_C_incomplete, true);
20082011

20092012
// TODO: should also guess some argument types

src/ansi-c/c_typecheck_type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,16 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type)
488488
// "A function declarator shall not specify a return type that
489489
// is a function type or an array type."
490490

491-
const typet &return_type=follow(type.return_type());
491+
const typet &decl_return_type = follow(type.return_type());
492492

493-
if(return_type.id()==ID_array)
493+
if(decl_return_type.id() == ID_array)
494494
{
495495
error().source_location=type.source_location();
496496
error() << "function must not return array" << eom;
497497
throw 0;
498498
}
499499

500-
if(return_type.id()==ID_code)
500+
if(decl_return_type.id() == ID_code)
501501
{
502502
error().source_location=type.source_location();
503503
error() << "function must not return function type" << eom;

0 commit comments

Comments
 (0)