Message ID | CANeU7Q=qfD=fpP1k1gHpUxek4ZUuau3drCDncYr5eE18Xiq4Zw@mail.gmail.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
On Wed, Apr 16, 2014 at 11:50 PM, Christopher Li <sparse@chrisli.org> wrote: > Here is a purpose patch with limited test. I expand the test to cover > more static test case. > > Cody, does this patch work for you? I apply the patch and push it out. Please let me know if it breaks any thing. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/17/2014 10:52 PM, Christopher Li wrote: > On Wed, Apr 16, 2014 at 11:50 PM, Christopher Li <sparse@chrisli.org> wrote: > >> Here is a purpose patch with limited test. I expand the test to cover >> more static test case. >> >> Cody, does this patch work for you? > > I apply the patch and push it out. > > Please let me know if it breaks any thing. > Looks fine to me Chris, thanks for putting this together. -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/parse.c b/parse.c index 70553f2..76aba40 100644 --- a/parse.c +++ b/parse.c @@ -1533,12 +1533,28 @@ static struct token *declaration_specifiers(struct token *tok return token; } +static struct token *abstract_array_static_declarator(struct token *token, int *has_ +{ + while (token->ident == &static_ident) { + if (*has_static) + warning(token->pos, "duplicate array static declarator"); + + *has_static = 1; + token = token->next; + } + return token; + +} + static struct token *abstract_array_declarator(struct token *token, struct symbol *s { struct expression *expr = NULL; + int has_static = 0; - while (match_idents(token, &restrict_ident, &__restrict_ident, &static_ident, - token = token->next; + token = abstract_array_static_declarator(token, &has_static); + + if (match_idents(token, &restrict_ident, &__restrict_ident, NULL)) + token = abstract_array_static_declarator(token->next, &has_static); token = parse_expression(token, &expr); sym->array_size = expr; return token; diff --git a/validation/abstract-array-declarator-static.c b/validation/abstract-arra index 23cbae0..b0af17b 100644 --- a/validation/abstract-array-declarator-static.c +++ b/validation/abstract-array-declarator-static.c @@ -1,6 +1,14 @@ -extern void f(int g[static 1]); +extern void f1(int g[static 1]); +extern void f2(int g[static restrict 1]); +extern void f3(int g[restrict static 1]); +extern void f4(int g[static restrict static 1]); /* duplicate static error */ +extern void f5(int g[restrict static static 1]); /* duplicate static error */ /* * check-name: abstract array declarator static + * check-error-start +abstract-array-declarator-static.c:5:38: warning: duplicate array static declarator