Skip to content

Commit 9c2b02f

Browse files
committed
Permit some (ab)use of void f(void) in place of a full function declaration
1 parent 838e780 commit 9c2b02f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/linking/linking.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,32 @@ void linkingt::duplicate_code_symbol(
597597
old_symbol.location=new_symbol.location;
598598
}
599599
}
600+
// Linux kernel uses void f(void) as generic prototype
601+
else if((old_t.return_type().id()==ID_empty &&
602+
old_t.parameters().empty() &&
603+
!old_t.has_ellipsis() &&
604+
old_symbol.value.is_nil()) ||
605+
(new_t.return_type().id()==ID_empty &&
606+
new_t.parameters().empty() &&
607+
!new_t.has_ellipsis() &&
608+
new_symbol.value.is_nil()))
609+
{
610+
// issue a warning
611+
link_warning(
612+
old_symbol,
613+
new_symbol,
614+
"ignoring conflicting void f(void) function declaration");
615+
616+
if(old_t.return_type().id()==ID_empty &&
617+
old_t.parameters().empty() &&
618+
!old_t.has_ellipsis() &&
619+
old_symbol.value.is_nil())
620+
{
621+
old_symbol.type=new_symbol.type;
622+
old_symbol.location=new_symbol.location;
623+
old_symbol.is_weak=new_symbol.is_weak;
624+
}
625+
}
600626
// mismatch on number of parameters is definitively an error
601627
else if((old_t.parameters().size()<new_t.parameters().size() &&
602628
!old_t.has_ellipsis()) ||

0 commit comments

Comments
 (0)