From b490078ef9248318195a6eb5ef5ae2cabf18e22f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 10 Nov 2018 11:43:08 +0000 Subject: [PATCH] Do not shadow the class member return_type Removed the temporary where it added no value and otherwise renamed it to descriptive names. --- src/ansi-c/c_typecheck_expr.cpp | 15 +++++++++------ src/ansi-c/c_typecheck_type.cpp | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index cf627c8d9c5..73078ddf482 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -927,10 +927,11 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression( code_function_callt &fc=to_code_function_call(last); - const auto &return_type = to_code_type(fc.function().type()).return_type(); - side_effect_expr_function_callt sideeffect( - fc.function(), fc.arguments(), return_type, fc.source_location()); + fc.function(), + fc.arguments(), + to_code_type(fc.function().type()).return_type(), + fc.source_location()); expr.type()=sideeffect.type(); @@ -1987,7 +1988,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call( // This is an undeclared function that's not a builtin. // Let's just add it. // We do a bit of return-type guessing, but just a bit. - typet return_type=signed_int_type(); + typet guessed_return_type = signed_int_type(); // The following isn't really right and sound, but there // 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( identifier=="realloc" || identifier=="reallocf" || identifier=="valloc") - return_type=pointer_type(void_type()); // void * + { + guessed_return_type = pointer_type(void_type()); // void * + } symbolt new_symbol; new_symbol.name=identifier; new_symbol.base_name=identifier; new_symbol.location=expr.source_location(); - new_symbol.type = code_typet({}, return_type); + new_symbol.type = code_typet({}, guessed_return_type); new_symbol.type.set(ID_C_incomplete, true); // TODO: should also guess some argument types diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index 060694cd963..63f24943d0e 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -486,16 +486,16 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) // "A function declarator shall not specify a return type that // is a function type or an array type." - const typet &return_type=follow(type.return_type()); + const typet &decl_return_type = follow(type.return_type()); - if(return_type.id()==ID_array) + if(decl_return_type.id() == ID_array) { error().source_location=type.source_location(); error() << "function must not return array" << eom; throw 0; } - if(return_type.id()==ID_code) + if(decl_return_type.id() == ID_code) { error().source_location=type.source_location(); error() << "function must not return function type" << eom;