Skip to content

Commit f0dd97d

Browse files
committed
C/C++ front-end: void-typed symbols are permitted when extern
This leaves it to the linker to resolve to some other type, and is quietly accepted by GCC. Required for building the Linux kernel. The changes in 9018306 were overly strict.
1 parent 36fa6f4 commit f0dd97d

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

regression/ansi-c/invalid_use_of_void1/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
extern void this_is_ok;
2+
13
struct a
24
{
35
#ifdef void_member

src/ansi-c/c_typecheck_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol)
103103
symbol.pretty_name=new_name;
104104
}
105105

106-
if(!symbol.is_type && symbol.type.id() == ID_empty)
106+
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
107107
{
108108
error().source_location = symbol.location;
109109
error() << "void-typed symbol not permitted" << eom;

src/cpp/cpp_typecheck_code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
448448
if(is_typedef)
449449
continue;
450450

451-
if(!symbol.is_type && symbol.type.id() == ID_empty)
451+
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
452452
{
453453
error().source_location = symbol.location;
454454
error() << "void-typed symbol not permitted" << eom;

src/cpp/cpp_typecheck_declaration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void cpp_typecheckt::convert_non_template_declaration(
148148
declaration_type, declaration.storage_spec(),
149149
declaration.member_spec(), declarator);
150150

151-
if(!symbol.is_type && symbol.type.id() == ID_empty)
151+
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
152152
{
153153
error().source_location = symbol.location;
154154
error() << "void-typed symbol not permitted" << eom;

0 commit comments

Comments
 (0)