Skip to content

Commit

Permalink
Avoid duplicate warning, merge with diffblue#1359/duplicate-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Jan 8, 2021
1 parent b309be6 commit 6b66928
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 65 deletions.
4 changes: 2 additions & 2 deletions regression/ansi-c/linking_conflicts1/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ main.c
other.c
^EXIT=(64|1)$
^SIGNAL=0$
error: conflicting function declarations 'bar'
error: conflicting function declarations 'bar2'
conflicting function declarations 'bar'
conflicting function declarations 'bar2'
--
^warning: ignoring
2 changes: 1 addition & 1 deletion regression/ansi-c/linking_conflicts2/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ main.c
other.c
^EXIT=(64|1)$
^SIGNAL=0$
error: conflicting function declarations 'foo'
conflicting function declarations 'foo'
--
^warning: ignoring
7 changes: 3 additions & 4 deletions src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
if(final_old.id()!=ID_code)
{
error().source_location=new_symbol.location;
error() << "error: function symbol '" << new_symbol.display_name()
error() << "function symbol '" << new_symbol.display_name()
<< "' redefined with a different type:\n"
<< "Original: " << to_string(old_symbol.type) << "\n"
<< " New: " << to_string(new_symbol.type) << eom;
Expand Down Expand Up @@ -617,9 +617,8 @@ void c_typecheck_baset::apply_asm_label(
if(asm_label_map[orig_name]!=asm_label)
{
error().source_location=symbol.location;
error() << "error: replacing asm renaming "
<< asm_label_map[orig_name] << " by "
<< asm_label << eom;
error() << "replacing asm renaming " << asm_label_map[orig_name]
<< " by " << asm_label << eom;
throw 0;
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/ansi-c/c_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,6 @@ void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code)

typecheck_expr(cond);

#if 0
if(cond.id()==ID_sideeffect &&
cond.get(ID_statement)==ID_assign)
{
warning("warning: assignment in if condition");
}
#endif

implicit_typecast_bool(cond);

if(code.then_case().get_statement() == ID_decl_block)
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr)
if(type0.get_bool(ID_C_constant))
{
error().source_location = op0.source_location();
error() << "error: '" << to_string(op0) << "' is constant" << eom;
error() << "'" << to_string(op0) << "' is constant" << eom;
throw 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_typecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void c_typecheck_baset::implicit_typecast(
for(const auto &tc_warning : c_typecast.warnings)
{
warning().source_location=expr.find_source_location();
warning() << "warning: conversion from '" << to_string(src_type) << "' to '"
warning() << "conversion from '" << to_string(src_type) << "' to '"
<< to_string(dest_type) << "': " << tc_warning << eom;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/cpp_declarator_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ symbolt &cpp_declarator_convertert::convert(
if(symbol_expr.id() != ID_type)
{
cpp_typecheck.error().source_location=name.source_location();
cpp_typecheck.error() << "error: expected type"
<< messaget::eom;
cpp_typecheck.error() << "expected type" << messaget::eom;
throw 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_bases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void cpp_typecheckt::add_base_components(
if(bases.find(from_name)!=bases.end())
{
error().source_location=to.source_location();
error() << "error: non-virtual base class " << from_name
error() << "non-virtual base class " << from_name
<< " inherited multiple times" << eom;
throw 0;
}
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
if(access == ID_private || access == ID_noaccess)
{
#if 0
error().source_location=code.source_location());
str << "error: constructor of '"
<< to_string(symbol_expr)
<< "' is not accessible";
error().source_location=code.find_source_location();
error() << "constructor of '"
<< to_string(symbol_expr)
<< "' is not accessible" << eom;
throw 0;
#endif
}
Expand Down
12 changes: 5 additions & 7 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ void cpp_typecheckt::typecheck_compound_type(
else
{
error().source_location=type.source_location();
error() << "error: compound tag '" << base_name
<< "' declared previously\n"
error() << "compound tag '" << base_name << "' declared previously\n"
<< "location of previous definition: " << symbol.location
<< eom;
throw 0;
Expand Down Expand Up @@ -1518,9 +1517,8 @@ bool cpp_typecheckt::get_component(
else
{
error().source_location=source_location;
error() << "error: member '" << component_name
<< "' is not accessible (" << component.get(ID_access) << ")"
<< eom;
error() << "member '" << component_name << "' is not accessible ("
<< component.get(ID_access) << ")" << eom;
throw 0;
}
}
Expand Down Expand Up @@ -1554,8 +1552,8 @@ bool cpp_typecheckt::get_component(
if(check_component_access(component, final_type))
{
error().source_location=source_location;
error() << "error: member '" << component_name
<< "' is not accessible" << eom;
error() << "member '" << component_name << "' is not accessible"
<< eom;
throw 0;
}

Expand Down
3 changes: 1 addition & 2 deletions src/cpp/cpp_typecheck_enum_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ void cpp_typecheckt::typecheck_enum_type(typet &type)
if(has_body)
{
error().source_location=type.source_location();
error() << "error: enum symbol '" << base_name
<< "' declared previously\n"
error() << "enum symbol '" << base_name << "' declared previously\n"
<< "location of previous definition: " << symbol.location << eom;
throw 0;
}
Expand Down
36 changes: 18 additions & 18 deletions src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_lvalue_to_rvalue(e1, expr.op1()))
{
error().source_location=e1.find_source_location();
error() << "error: lvalue to rvalue conversion" << eom;
error() << "lvalue to rvalue conversion" << eom;
throw 0;
}
}
Expand All @@ -154,7 +154,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_array_to_pointer(e1, expr.op1()))
{
error().source_location=e1.find_source_location();
error() << "error: array to pointer conversion" << eom;
error() << "array to pointer conversion" << eom;
throw 0;
}
}
Expand All @@ -165,7 +165,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_function_to_pointer(e1, expr.op1()))
{
error().source_location=e1.find_source_location();
error() << "error: function to pointer conversion" << eom;
error() << "function to pointer conversion" << eom;
throw 0;
}
}
Expand All @@ -176,7 +176,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_lvalue_to_rvalue(e2, expr.op2()))
{
error().source_location=e2.find_source_location();
error() << "error: lvalue to rvalue conversion" << eom;
error() << "lvalue to rvalue conversion" << eom;
throw 0;
}
}
Expand All @@ -187,7 +187,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_array_to_pointer(e2, expr.op2()))
{
error().source_location=e2.find_source_location();
error() << "error: array to pointer conversion" << eom;
error() << "array to pointer conversion" << eom;
throw 0;
}
}
Expand All @@ -198,7 +198,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
if(!standard_conversion_function_to_pointer(e2, expr.op2()))
{
error().source_location=expr.find_source_location();
error() << "error: function to pointer conversion" << eom;
error() << "function to pointer conversion" << eom;
throw 0;
}
}
Expand All @@ -215,7 +215,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
else
{
error().source_location=expr.find_source_location();
error() << "error: bad types for operands" << eom;
error() << "bad types for operands" << eom;
throw 0;
}
return;
Expand Down Expand Up @@ -268,7 +268,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
else
{
error().source_location=expr.find_source_location();
error() << "error: types are incompatible.\n"
error() << "types are incompatible.\n"
<< "I got '" << type2cpp(expr.op1().type(), *this) << "' and '"
<< type2cpp(expr.op2().type(), *this) << "'." << eom;
throw 0;
Expand Down Expand Up @@ -701,7 +701,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
if(code_type.get_bool(ID_C_is_virtual))
{
error().source_location=expr.source_location();
error() << "error: pointers to virtual methods"
error() << "pointers to virtual methods"
<< " are currently not implemented" << eom;
throw 0;
}
Expand Down Expand Up @@ -1062,7 +1062,7 @@ void cpp_typecheckt::typecheck_expr_member(
if(expr.operands().size()!=1)
{
error().source_location=expr.find_source_location();
error() << "error: member operator expects one operand" << eom;
error() << "member operator expects one operand" << eom;
throw 0;
}

Expand Down Expand Up @@ -1094,7 +1094,7 @@ void cpp_typecheckt::typecheck_expr_member(
followed_op0_type.id()!=ID_union)
{
error().source_location=expr.find_source_location();
error() << "error: member operator requires struct/union type "
error() << "member operator requires struct/union type "
<< "on left hand side but got '" << to_string(followed_op0_type)
<< "'" << eom;
throw 0;
Expand All @@ -1106,7 +1106,7 @@ void cpp_typecheckt::typecheck_expr_member(
if(type.is_incomplete())
{
error().source_location = expr.find_source_location();
error() << "error: member operator got incomplete type "
error() << "member operator got incomplete type "
<< "on left hand side" << eom;
throw 0;
}
Expand Down Expand Up @@ -1153,7 +1153,7 @@ void cpp_typecheckt::typecheck_expr_member(
to_code_type(symbol_expr.type()).return_type().id() == ID_constructor)
{
error().source_location=expr.find_source_location();
error() << "error: member '"
error() << "member '"
<< lookup(symbol_expr.get(ID_identifier)).base_name
<< "' is a constructor" << eom;
throw 0;
Expand All @@ -1167,7 +1167,7 @@ void cpp_typecheckt::typecheck_expr_member(
if(pcomp.is_nil())
{
error().source_location=expr.find_source_location();
error() << "error: '" << symbol_expr.get(ID_identifier)
error() << "'" << symbol_expr.get(ID_identifier)
<< "' is not static member "
<< "of class '" << to_string(op0.type()) << "'" << eom;
throw 0;
Expand Down Expand Up @@ -1209,8 +1209,8 @@ void cpp_typecheckt::typecheck_expr_member(
else
{
error().source_location=expr.find_source_location();
error() << "error: member '" << component_name << "' of '"
<< to_string(type) << "' not found" << eom;
error() << "member '" << component_name << "' of '" << to_string(type)
<< "' not found" << eom;
throw 0;
}

Expand Down Expand Up @@ -1239,7 +1239,7 @@ void cpp_typecheckt::typecheck_expr_ptrmember(
if(expr.operands().size()!=1)
{
error().source_location=expr.find_source_location();
error() << "error: ptrmember operator expects one operand" << eom;
error() << "ptrmember operator expects one operand" << eom;
throw 0;
}

Expand All @@ -1250,7 +1250,7 @@ void cpp_typecheckt::typecheck_expr_ptrmember(
if(op.type().id() != ID_pointer)
{
error().source_location=expr.find_source_location();
error() << "error: ptrmember operator requires pointer type "
error() << "ptrmember operator requires pointer type "
<< "on left hand side, but got '" << to_string(op.type()) << "'"
<< eom;
throw 0;
Expand Down
9 changes: 4 additions & 5 deletions src/cpp/cpp_typecheck_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,8 @@ exprt cpp_typecheck_resolvet::resolve(
return nil_exprt();

cpp_typecheck.error().source_location=result.source_location());
cpp_typecheck.str
<< "error: member '" << result.get(ID_component_name)
<< "' is not accessible";
cpp_typecheck.error() << "member '" << result.get(ID_component_name)
<< "' is not accessible" << messaget::eom;
throw 0;
#endif
}
Expand All @@ -1667,7 +1666,7 @@ exprt cpp_typecheck_resolvet::resolve(
cpp_typecheck.error().source_location=source_location;

cpp_typecheck.error()
<< "error: expected expression, but got type '"
<< "expected expression, but got type '"
<< cpp_typecheck.to_string(result.type()) << "'" << messaget::eom;

throw 0;
Expand All @@ -1683,7 +1682,7 @@ exprt cpp_typecheck_resolvet::resolve(
cpp_typecheck.error().source_location=source_location;

cpp_typecheck.error()
<< "error: expected type, but got expression '"
<< "expected type, but got expression '"
<< cpp_typecheck.to_string(result) << "'" << messaget::eom;

throw 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void cpp_typecheckt::typecheck_type(typet &type)
if(symbol_expr.id()!=ID_type)
{
error().source_location=type.source_location();
error() << "error: expected type" << eom;
error() << "expected type" << eom;
throw 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/goto-programs/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ void goto_convertt::do_function_call_symbol(
if(ns.lookup(identifier, symbol))
{
error().source_location=function.find_source_location();
error() << "error: function '" << identifier << "' not found" << eom;
error() << "function '" << identifier << "' not found" << eom;
throw 0;
}

if(symbol->type.id()!=ID_code)
{
error().source_location=function.find_source_location();
error() << "error: function '" << identifier
<< "' type mismatch: expected code" << eom;
error() << "function '" << identifier << "' type mismatch: expected code"
<< eom;
throw 0;
}

Expand Down
9 changes: 4 additions & 5 deletions src/linking/linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,7 @@ void linkingt::link_error(
{
error().source_location=new_symbol.location;

error() << "error: " << msg << " '" << old_symbol.display_name() << "'"
<< '\n';
error() << msg << " '" << old_symbol.display_name() << "'" << '\n';
error() << "old definition in module '" << old_symbol.module << "' "
<< old_symbol.location << '\n'
<< type_to_string_verbose(old_symbol) << '\n';
Expand All @@ -402,8 +401,8 @@ void linkingt::link_warning(
{
warning().source_location=new_symbol.location;

warning() << "warning: " << msg << " " << quote_begin
<< old_symbol.display_name() << quote_end << '\n';
warning() << msg << " " << quote_begin << old_symbol.display_name()
<< quote_end << '\n';
warning() << "old definition in module " << old_symbol.module << " "
<< old_symbol.location << '\n'
<< type_to_string_verbose(old_symbol) << '\n';
Expand Down Expand Up @@ -1058,7 +1057,7 @@ void linkingt::duplicate_object_symbol(
{
warning().source_location=new_symbol.location;

warning() << "warning: conflicting initializers for"
warning() << "conflicting initializers for"
<< " variable " << quote_begin << old_symbol.name << quote_end
<< '\n';
warning() << "using old value in module " << old_symbol.module << " "
Expand Down

0 comments on commit 6b66928

Please sign in to comment.