Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate "warning:" or "error:" output #1359

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'bar'$
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'bar2'$
--
tautschnig marked this conversation as resolved.
Show resolved Hide resolved
^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'
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'foo'$
--
^warning: ignoring
4 changes: 2 additions & 2 deletions regression/cbmc/incomplete-structs/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
typesmain.c
types1.c types2.c types3.c
warning: pointer parameter types differ between declaration and definition "bar"
warning: pointer parameter types differ between declaration and definition "foo"
^file \S+\.c line \d+: pointer parameter types differ between declaration and definition 'bar'$
^file \S+\.c line \d+: pointer parameter types differ between declaration and definition 'foo'$
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
Expand Down
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 @@ -375,7 +375,7 @@
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()

Check warning on line 378 in src/ansi-c/c_typecheck_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/ansi-c/c_typecheck_base.cpp#L378

Added line #L378 was not covered by tests
<< "' redefined with a different type:\n"
<< "Original: " << to_string(old_symbol.type) << "\n"
<< " New: " << to_string(new_symbol.type) << eom;
Expand Down Expand Up @@ -679,9 +679,8 @@
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;

Check warning on line 683 in src/ansi-c/c_typecheck_base.cpp

View check run for this annotation

Codecov / codecov/patch

src/ansi-c/c_typecheck_base.cpp#L682-L683

Added lines #L682 - L683 were not covered by tests
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 @@ -629,14 +629,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 @@ -1883,7 +1883,7 @@
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;

Check warning on line 1886 in src/ansi-c/c_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/ansi-c/c_typecheck_expr.cpp#L1886

Added line #L1886 was not covered by tests
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 @@ -176,8 +176,7 @@
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;

Check warning on line 179 in src/cpp/cpp_declarator_converter.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_declarator_converter.cpp#L179

Added line #L179 was not covered by tests
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 @@ -132,7 +132,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 @@ -278,10 +278,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 @@ -211,8 +211,7 @@
else
{
error().source_location=type.source_location();
error() << "error: compound tag '" << base_name
<< "' declared previously\n"
error() << "compound tag '" << base_name << "' declared previously\n"

Check warning on line 214 in src/cpp/cpp_typecheck_compound_type.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_compound_type.cpp#L214

Added line #L214 was not covered by tests
<< "location of previous definition: " << symbol.location
<< eom;
throw 0;
Expand Down Expand Up @@ -1522,9 +1521,8 @@
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 @@ -1566,8 +1564,8 @@
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;

Check warning on line 1568 in src/cpp/cpp_typecheck_compound_type.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_compound_type.cpp#L1567-L1568

Added lines #L1567 - L1568 were not covered by tests
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 @@ -133,8 +133,7 @@
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"

Check warning on line 136 in src/cpp/cpp_typecheck_enum_type.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_enum_type.cpp#L136

Added line #L136 was not covered by tests
<< "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 @@ -145,7 +145,7 @@
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;

Check warning on line 148 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L148

Added line #L148 was not covered by tests
throw 0;
}
}
Expand All @@ -156,7 +156,7 @@
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;

Check warning on line 159 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L159

Added line #L159 was not covered by tests
throw 0;
}
}
Expand All @@ -167,7 +167,7 @@
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;

Check warning on line 170 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L170

Added line #L170 was not covered by tests
throw 0;
}
}
Expand All @@ -178,7 +178,7 @@
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;

Check warning on line 181 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L181

Added line #L181 was not covered by tests
throw 0;
}
}
Expand All @@ -189,7 +189,7 @@
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;

Check warning on line 192 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L192

Added line #L192 was not covered by tests
throw 0;
}
}
Expand All @@ -200,7 +200,7 @@
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;

Check warning on line 203 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L203

Added line #L203 was not covered by tests
throw 0;
}
}
Expand All @@ -217,7 +217,7 @@
else
{
error().source_location=expr.find_source_location();
error() << "error: bad types for operands" << eom;
error() << "bad types for operands" << eom;

Check warning on line 220 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L220

Added line #L220 was not covered by tests
throw 0;
}
return;
Expand Down Expand Up @@ -272,7 +272,7 @@
else
{
error().source_location=expr.find_source_location();
error() << "error: types are incompatible.\n"
error() << "types are incompatible.\n"

Check warning on line 275 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L275

Added line #L275 was not covered by tests
<< "I got '" << type2cpp(expr.op1().type(), *this) << "' and '"
<< type2cpp(expr.op2().type(), *this) << "'." << eom;
throw 0;
Expand Down Expand Up @@ -706,7 +706,7 @@
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"

Check warning on line 709 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L709

Added line #L709 was not covered by tests
<< " are currently not implemented" << eom;
throw 0;
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@
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;

Check warning on line 1071 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1071

Added line #L1071 was not covered by tests
throw 0;
}

Expand Down Expand Up @@ -1097,7 +1097,7 @@
if(op0.type().id() != ID_struct_tag && op0.type().id() != ID_union_tag)
{
error().source_location=expr.find_source_location();
error() << "error: member operator requires struct/union type "
error() << "member operator requires struct/union type "

Check warning on line 1100 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1100

Added line #L1100 was not covered by tests
<< "on left hand side but got '" << to_string(op0.type()) << "'"
<< eom;
throw 0;
Expand All @@ -1113,7 +1113,7 @@
if(type.is_incomplete())
{
error().source_location = expr.find_source_location();
error() << "error: member operator got incomplete type "
error() << "member operator got incomplete type "

Check warning on line 1116 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1116

Added line #L1116 was not covered by tests
<< "on left hand side" << eom;
throw 0;
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@
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 @@ -1175,7 +1175,7 @@
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 @@ -1217,8 +1217,8 @@
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;

Check warning on line 1221 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1221

Added line #L1221 was not covered by tests
throw 0;
}

Expand All @@ -1243,7 +1243,7 @@
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;

Check warning on line 1246 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1246

Added line #L1246 was not covered by tests
throw 0;
}

Expand All @@ -1254,7 +1254,7 @@
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 "

Check warning on line 1257 in src/cpp/cpp_typecheck_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_expr.cpp#L1257

Added line #L1257 was not covered by tests
<< "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 @@ -1675,9 +1675,8 @@
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 @@ -1693,7 +1692,7 @@
cpp_typecheck.error().source_location=source_location;

cpp_typecheck.error()
<< "error: expected expression, but got type '"
<< "expected expression, but got type '"

Check warning on line 1695 in src/cpp/cpp_typecheck_resolve.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_resolve.cpp#L1695

Added line #L1695 was not covered by tests
<< cpp_typecheck.to_string(result.type()) << "'" << messaget::eom;

throw 0;
Expand All @@ -1709,7 +1708,7 @@
cpp_typecheck.error().source_location=source_location;

cpp_typecheck.error()
<< "error: expected type, but got expression '"
<< "expected type, but got expression '"

Check warning on line 1711 in src/cpp/cpp_typecheck_resolve.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_resolve.cpp#L1711

Added line #L1711 was not covered by tests
<< 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 @@ -61,7 +61,7 @@
if(symbol_expr.id()!=ID_type)
{
error().source_location=type.source_location();
error() << "error: expected type" << eom;
error() << "expected type" << eom;

Check warning on line 64 in src/cpp/cpp_typecheck_type.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/cpp_typecheck_type.cpp#L64

Added line #L64 was not covered by tests
throw 0;
}

Expand Down
5 changes: 4 additions & 1 deletion src/goto-cc/armcc_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
has_prefix(base_name, "goto-link");
#endif

const auto default_verbosity =
cmdline.isset("diag_warning=") ? messaget::M_WARNING : messaget::M_ERROR;

Check warning on line 49 in src/goto-cc/armcc_mode.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-cc/armcc_mode.cpp#L48-L49

Added lines #L48 - L49 were not covered by tests
const auto verbosity = messaget::eval_verbosity(
cmdline.get_value("verbosity"), messaget::M_ERROR, message_handler);
cmdline.get_value("verbosity"), default_verbosity, message_handler);
message_handler.print_warnings_as_errors(cmdline.isset("diag_error="));

Check warning on line 52 in src/goto-cc/armcc_mode.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-cc/armcc_mode.cpp#L51-L52

Added lines #L51 - L52 were not covered by tests

messaget log{message_handler};
log.debug() << "ARM mode" << messaget::eom;
Expand Down
1 change: 1 addition & 0 deletions src/goto-cc/as_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
messaget::M_WARNING : messaget::M_ERROR;
messaget::eval_verbosity(
cmdline.get_value("verbosity"), default_verbosity, message_handler);
message_handler.print_warnings_as_errors(cmdline.isset("fatal-warnings"));

Check warning on line 113 in src/goto-cc/as_mode.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-cc/as_mode.cpp#L113

Added line #L113 was not covered by tests

if(act_as_as86)
{
Expand Down
3 changes: 3 additions & 0 deletions src/goto-cc/cl_message_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

std::ostringstream formatted_message;

if(level == messaget::M_WARNING && warnings_are_errors)
formatted_message << "error: warning treated as error\n";

Check warning on line 29 in src/goto-cc/cl_message_handler.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-cc/cl_message_handler.cpp#L28-L29

Added lines #L28 - L29 were not covered by tests

const irep_idt file = location.get_file();
const std::string &line = id2string(location.get_line());
formatted_message << file << '(' << line << "): ";
Expand Down
Loading
Loading