Skip to content

Commit d93e564

Browse files
committed
GCC attribute alias should not trigger warning
We spuriously warned about an extern symbol with value, where it was only our handling of the "alias" attribute that introduced that value in the first place. While at it, make that warning more useful.
1 parent d932d6f commit d93e564

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
CORE gcc-only
22
main.c
3-
3+
-Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
'extern' symbol 'my_ids_table' should not have an initializer
78
^warning: ignoring
89
^CONVERSION ERROR$

src/ansi-c/c_typecheck_base.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol)
7171
new_name=root_name;
7272
symbol.is_static_lifetime=true;
7373

74-
if(symbol.value.is_not_nil())
74+
if(symbol.value.is_not_nil() && !symbol.is_macro)
7575
{
7676
// According to the C standard this should be an error, but at least some
7777
// versions of Visual Studio insist to use this in their C library, and
7878
// GCC just warns as well.
7979
warning().source_location = symbol.value.find_source_location();
80-
warning() << "`extern' symbol should not have an initializer" << eom;
80+
warning() << "'extern' symbol '" << new_name
81+
<< "' should not have an initializer" << eom;
8182
}
8283
}
8384
else if(!is_function && symbol.value.id()==ID_code)

0 commit comments

Comments
 (0)