[PATCH 3/4] Accept comma-separated list for function declarations.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The declaration of a function without prototype is currently
silently accepted by sparse but a warning is issued for
'old-style' declarations:
	... warning: non-ANSI function declaration ...

However, the difference between these two cases is made by
checking if a ';' directly follow the parentheses. So:
	int foo();
is silently accepted, while a warning is issued for:
	int foo(a) int a;
but also for:
	int foo(), bar();
This last case, while unusual, is not less ANSI than a simple
'int foo();'. It's just detected so because there is no ';'
directly after the first '()'.

Fix this by also using ',' to detect the end of function
declarations and their ANSIness.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse.c b/parse.c
index ec145601d..eaa3ac2e2 100644
--- a/parse.c
+++ b/parse.c
@@ -1750,7 +1750,7 @@ static enum kind which_func(struct token *token,
 
 	if (next->special == ')') {
 		/* don't complain about those */
-		if (!n || match_op(next->next, ';'))
+		if (!n || match_op(next->next, ';') || match_op(next->next, ','))
 			return Empty;
 		warning(next->pos,
 			"non-ANSI function declaration of function '%s'",
-- 
2.19.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux