From patchwork Tue Apr 15 23:08:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cody@linux.vnet.ibm.com X-Patchwork-Id: 3995851 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31CCC9F2BA for ; Tue, 15 Apr 2014 23:09:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 601412025B for ; Tue, 15 Apr 2014 23:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A3E020259 for ; Tue, 15 Apr 2014 23:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750908AbaDOXJI (ORCPT ); Tue, 15 Apr 2014 19:09:08 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:55855 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751217AbaDOXJF (ORCPT ); Tue, 15 Apr 2014 19:09:05 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Apr 2014 19:09:04 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 Apr 2014 19:09:02 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 0EAE86E801F for ; Tue, 15 Apr 2014 19:08:55 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp22035.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3FN910K1769764 for ; Tue, 15 Apr 2014 23:09:01 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s3FN90A5023426 for ; Tue, 15 Apr 2014 19:09:01 -0400 Received: from localdomain.local ([9.80.109.194]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s3FN90vr023398; Tue, 15 Apr 2014 19:09:00 -0400 Received: from localhost (localhost [127.0.0.1]) by localdomain.local (Postfix) with ESMTP id 95359181040; Tue, 15 Apr 2014 16:08:59 -0700 (PDT) From: Cody P Schafer To: linux-sparse@vger.kernel.org Cc: Cody P Schafer Subject: [PATCH] parse: support c99 [static ...] in abstract array declarators Date: Tue, 15 Apr 2014 16:08:57 -0700 Message-Id: <1397603337-28016-1-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.2 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14041523-5806-0000-0000-000024A33166 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Makes sparse a little more accepting than the standard: we accept any number of ["static", "restrict"] repeated in any order, while the n1570 specifies (in 6.7.6.2.3) that either type-qualifiers (ie: "restrict") come first and are followed by "static" or the opposite ("static" then type-qualifiers). Also add a test. Signed-off-by: Cody P Schafer --- ident-list.h | 1 + parse.c | 2 +- validation/abstract-array-declarator-static.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 validation/abstract-array-declarator-static.c diff --git a/ident-list.h b/ident-list.h index e93aae7..c0fc18f 100644 --- a/ident-list.h +++ b/ident-list.h @@ -91,6 +91,7 @@ IDENT(artificial); IDENT(__artificial__); IDENT(leaf); IDENT(__leaf__); IDENT(vector_size); IDENT(__vector_size__); IDENT(error); IDENT(__error__); +IDENT(static); /* Preprocessor idents. Direct use of __IDENT avoids mentioning the keyword diff --git a/parse.c b/parse.c index 9cc5f65..cbe3af4 100644 --- a/parse.c +++ b/parse.c @@ -1532,7 +1532,7 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo { struct expression *expr = NULL; - if (match_idents(token, &restrict_ident, &__restrict_ident, NULL)) + while (match_idents(token, &restrict_ident, &__restrict_ident, &static_ident, NULL)) token = token->next; token = parse_expression(token, &expr); sym->array_size = expr; diff --git a/validation/abstract-array-declarator-static.c b/validation/abstract-array-declarator-static.c new file mode 100644 index 0000000..23cbae0 --- /dev/null +++ b/validation/abstract-array-declarator-static.c @@ -0,0 +1,6 @@ + +extern void f(int g[static 1]); + +/* + * check-name: abstract array declarator static + */