Skip to content

Commit f9f84f3

Browse files
authored
Merge pull request #1359 from tautschnig/duplicate-warning
Avoid duplicate "warning:" or "error:" output
2 parents 1ed7b2f + 613289b commit f9f84f3

28 files changed

+103
-74
lines changed

regression/ansi-c/linking_conflicts1/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
other.c
44
^EXIT=(64|1)$
55
^SIGNAL=0$
6-
error: conflicting function declarations 'bar'
7-
error: conflicting function declarations 'bar2'
6+
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'bar'$
7+
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'bar2'$
88
--
99
^warning: ignoring

regression/ansi-c/linking_conflicts2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ main.c
33
other.c
44
^EXIT=(64|1)$
55
^SIGNAL=0$
6-
error: conflicting function declarations 'foo'
6+
^\S+\.c(:\d+:\d+|\(\d+\)): error: conflicting function declarations 'foo'$
77
--
88
^warning: ignoring

regression/cbmc/incomplete-structs/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
typesmain.c
33
types1.c types2.c types3.c
4-
warning: pointer parameter types differ between declaration and definition "bar"
5-
warning: pointer parameter types differ between declaration and definition "foo"
4+
^file \S+\.c line \d+: pointer parameter types differ between declaration and definition 'bar'$
5+
^file \S+\.c line \d+: pointer parameter types differ between declaration and definition 'foo'$
66
^VERIFICATION SUCCESSFUL$
77
^EXIT=0$
88
^SIGNAL=0$

src/ansi-c/c_typecheck_base.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
375375
if(final_old.id()!=ID_code)
376376
{
377377
error().source_location=new_symbol.location;
378-
error() << "error: function symbol '" << new_symbol.display_name()
378+
error() << "function symbol '" << new_symbol.display_name()
379379
<< "' redefined with a different type:\n"
380380
<< "Original: " << to_string(old_symbol.type) << "\n"
381381
<< " New: " << to_string(new_symbol.type) << eom;
@@ -679,9 +679,8 @@ void c_typecheck_baset::apply_asm_label(
679679
if(asm_label_map[orig_name]!=asm_label)
680680
{
681681
error().source_location=symbol.location;
682-
error() << "error: replacing asm renaming "
683-
<< asm_label_map[orig_name] << " by "
684-
<< asm_label << eom;
682+
error() << "replacing asm renaming " << asm_label_map[orig_name]
683+
<< " by " << asm_label << eom;
685684
throw 0;
686685
}
687686
}

src/ansi-c/c_typecheck_code.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,6 @@ void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code)
629629

630630
typecheck_expr(cond);
631631

632-
#if 0
633-
if(cond.id()==ID_sideeffect &&
634-
cond.get(ID_statement)==ID_assign)
635-
{
636-
warning("warning: assignment in if condition");
637-
}
638-
#endif
639-
640632
implicit_typecast_bool(cond);
641633

642634
if(code.then_case().get_statement() == ID_decl_block)

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr)
18831883
if(type0.get_bool(ID_C_constant))
18841884
{
18851885
error().source_location = op0.source_location();
1886-
error() << "error: '" << to_string(op0) << "' is constant" << eom;
1886+
error() << "'" << to_string(op0) << "' is constant" << eom;
18871887
throw 0;
18881888
}
18891889

src/ansi-c/c_typecheck_typecast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void c_typecheck_baset::implicit_typecast(
3434
for(const auto &tc_warning : c_typecast.warnings)
3535
{
3636
warning().source_location=expr.find_source_location();
37-
warning() << "warning: conversion from '" << to_string(src_type) << "' to '"
37+
warning() << "conversion from '" << to_string(src_type) << "' to '"
3838
<< to_string(dest_type) << "': " << tc_warning << eom;
3939
}
4040
}

src/cpp/cpp_declarator_converter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ symbolt &cpp_declarator_convertert::convert(
176176
if(symbol_expr.id() != ID_type)
177177
{
178178
cpp_typecheck.error().source_location=name.source_location();
179-
cpp_typecheck.error() << "error: expected type"
180-
<< messaget::eom;
179+
cpp_typecheck.error() << "expected type" << messaget::eom;
181180
throw 0;
182181
}
183182

src/cpp/cpp_typecheck_bases.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void cpp_typecheckt::add_base_components(
132132
if(bases.find(from_name)!=bases.end())
133133
{
134134
error().source_location=to.source_location();
135-
error() << "error: non-virtual base class " << from_name
135+
error() << "non-virtual base class " << from_name
136136
<< " inherited multiple times" << eom;
137137
throw 0;
138138
}

src/cpp/cpp_typecheck_code.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
278278
if(access == ID_private || access == ID_noaccess)
279279
{
280280
#if 0
281-
error().source_location=code.source_location());
282-
str << "error: constructor of '"
283-
<< to_string(symbol_expr)
284-
<< "' is not accessible";
281+
error().source_location=code.find_source_location();
282+
error() << "constructor of '"
283+
<< to_string(symbol_expr)
284+
<< "' is not accessible" << eom;
285285
throw 0;
286286
#endif
287287
}

0 commit comments

Comments
 (0)