Warn about non-empty identifier list outside of definition
PATCH 6/7 Warn about non-empty identifier list outside of definition
Signed-off-by Al Viro <[email protected]>
--- parse.c | 12 ++++++++++-- validation/nested-declarator2.c | 14 ++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-)
parse.c +10 -2
@@ -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; }
validation/nested-declarator2.c +8 -6
@@ -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: */
Signature · 1 line
1.5.6.6