Skip to content

Commit be27605

Browse files
committed
Linking: shadowed symbols should not trigger warnings
The Unix linker silently ignores (re-)definitions when these are already present. We may even internally generate multiple definitions for GCC's built-ins, warnings about which would always be spurious. This avoids spurious build failures when linking with -Werror.
1 parent f2240be commit be27605

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

regression/goto-cc-file-local/name-clash-with-suffix/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use_find out-file-counter final-link wall suffix assertion-check
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7-
^.*warning: function '__CPROVER_file_local_main_c_static_fun' in module 'main' is shadowed by a definition in module 'main'
7+
^.*: function '__CPROVER_file_local_main_c_static_fun' in module 'main' is shadowed by a definition in module 'main'
88
^warning: ignoring
99
^\*\*\*\* WARNING: no body for function
1010
--

regression/goto-cc-file-local/name-clash/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ foo/bar/baz/main.c
33
use_find out-file-counter final-link wall
44
^EXIT=0$
55
^SIGNAL=0$
6-
^.*warning: function '__CPROVER_file_local_main_c_static_fun' in module 'main' is shadowed by a definition in module 'main'
6+
^.*: function '__CPROVER_file_local_main_c_static_fun' in module 'main' is shadowed by a definition in module 'main'
77
--
88
^warning: ignoring
99
^\*\*\*\* WARNING: no body for function

src/linking/linking.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,12 @@ void linkingt::duplicate_code_symbol(
796796
else if(base_type_eq(old_symbol.type, new_symbol.type, ns))
797797
{
798798
// keep the one in old_symbol -- libraries come last!
799-
warning().source_location=new_symbol.location;
799+
debug().source_location = new_symbol.location;
800800

801-
warning() << "function '" << old_symbol.name << "' in module '"
802-
<< new_symbol.module
803-
<< "' is shadowed by a definition in module '"
804-
<< old_symbol.module << "'" << eom;
801+
debug() << "function '" << old_symbol.name << "' in module '"
802+
<< new_symbol.module
803+
<< "' is shadowed by a definition in module '"
804+
<< old_symbol.module << "'" << eom;
805805
}
806806
else
807807
link_error(

0 commit comments

Comments
 (0)