linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/7] Warn about non-empty identifier list outside of definition
@ 2009-02-14 12:25 Al Viro
  0 siblings, 0 replies; only message in thread
From: Al Viro @ 2009-02-14 12:25 UTC (permalink / raw)
  To: linux-sparse


Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 parse.c                         |   12 ++++++++++--
 validation/nested-declarator2.c |   14 ++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/parse.c b/parse.c
index 70cf2fb..9fe87e6 100644
--- a/parse.c
+++ b/parse.c
@@ -1271,8 +1271,16 @@ static enum kind which_kind(struct token *token, struct token **p,
 	if (token_type(next) == TOKEN_IDENT) {
 		if (lookup_type(next))
 			return (dont_nest || prefer_abstract) ? Proto : Nested;
-		if (dont_nest)
-			return (next == token->next) ? K_R : Bad_Func;
+		if (dont_nest) {
+			/* attributes in the K&R identifier list */
+			if (next != token->next)
+				return Bad_Func;
+			/* identifier list not in definition; complain */
+			if (prefer_abstract)
+				warning(token->pos,
+					"identifier list not in definition");
+			return K_R;
+		}
 		return Nested;
 	}
 
diff --git a/validation/nested-declarator2.c b/validation/nested-declarator2.c
index 700c802..795d01f 100644
--- a/validation/nested-declarator2.c
+++ b/validation/nested-declarator2.c
@@ -21,6 +21,7 @@ int y;
 static void w2(int ());
 static void w3(...);
 static void f9(__attribute__((mode(DI))) T);
+static void w4(int f(x,y));
 static void bad1(__attribute__((mode(DI))) x);
 static int (-bad2);
 static void [2](*bad3);
@@ -30,11 +31,12 @@ static void [2](*bad3);
 nested-declarator2.c:17:1: warning: non-ANSI definition of function 'w1'
 nested-declarator2.c:21:21: warning: non-ANSI function declaration of function '<noident>'
 nested-declarator2.c:22:16: warning: variadic functions must have one named argument
-nested-declarator2.c:24:44: error: Expected ) in function declarator
-nested-declarator2.c:24:44: error: got x
-nested-declarator2.c:25:13: error: Expected ) in nested declarator
-nested-declarator2.c:25:13: error: got -
-nested-declarator2.c:26:17: error: Expected ) in function declarator
-nested-declarator2.c:26:17: error: got *
+nested-declarator2.c:24:21: warning: identifier list not in definition
+nested-declarator2.c:25:44: error: Expected ) in function declarator
+nested-declarator2.c:25:44: error: got x
+nested-declarator2.c:26:13: error: Expected ) in nested declarator
+nested-declarator2.c:26:13: error: got -
+nested-declarator2.c:27:17: error: Expected ) in function declarator
+nested-declarator2.c:27:17: error: got *
  * check-error-end:
  */
-- 
1.5.6.6



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-14 12:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-14 12:25 [PATCH 6/7] Warn about non-empty identifier list outside of definition Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).