Skip to content

C/C++ front-end: void-typed symbols are permitted when extern #5732

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

Merged
merged 1 commit into from
Jan 10, 2021
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
2 changes: 2 additions & 0 deletions regression/ansi-c/invalid_use_of_void1/main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern void this_is_ok;

struct a
{
#ifdef void_member
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol)
symbol.pretty_name=new_name;
}

if(!symbol.is_type && symbol.type.id() == ID_empty)
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
{
error().source_location = symbol.location;
error() << "void-typed symbol not permitted" << eom;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
if(is_typedef)
continue;

if(!symbol.is_type && symbol.type.id() == ID_empty)
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
{
error().source_location = symbol.location;
error() << "void-typed symbol not permitted" << eom;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void cpp_typecheckt::convert_non_template_declaration(
declaration_type, declaration.storage_spec(),
declaration.member_spec(), declarator);

if(!symbol.is_type && symbol.type.id() == ID_empty)
if(!symbol.is_type && !symbol.is_extern && symbol.type.id() == ID_empty)
{
error().source_location = symbol.location;
error() << "void-typed symbol not permitted" << eom;
Expand Down