linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Christopher Li <sparse@chrisli.org>, linux-sparse@vger.kernel.org
Subject: Allow array declarators to have 'restrict' in them
Date: Thu, 18 Jun 2009 09:44:54 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0906180940490.16802@localhost.localdomain> (raw)


Otherwise sparse is very unhappy about the current glibc header files 
(aio.h, netdb.h. regex.h and spawn.h at a minimum).

It's a hack, and not a proper parsing with saving the information. It just 
ignores any "restrict" keyword at the start of an abstract array 
declaration, but it's better than what we have now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 ident-list.h |    1 +
 parse.c      |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/ident-list.h b/ident-list.h
index 29ddeca..0ee81bc 100644
--- a/ident-list.h
+++ b/ident-list.h
@@ -83,6 +83,7 @@ IDENT(stdcall); IDENT(__stdcall__);
 IDENT(fastcall); IDENT(__fastcall__);
 IDENT(dllimport); IDENT(__dllimport__);
 IDENT(dllexport); IDENT(__dllexport__);
+IDENT(restrict); IDENT(__restrict);
 
 /* Preprocessor idents.  Direct use of __IDENT avoids mentioning the keyword
  * itself by name, preventing these tokens from expanding when compiling
diff --git a/parse.c b/parse.c
index fbeebb0..df696e5 100644
--- a/parse.c
+++ b/parse.c
@@ -1431,6 +1431,8 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo
 {
 	struct expression *expr = NULL;
 
+	if (match_idents(token, &restrict_ident, &__restrict_ident, NULL))
+		token = token->next;
 	token = parse_expression(token, &expr);
 	sym->array_size = expr;
 	return token;


             reply	other threads:[~2009-06-18 16:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-18 16:44 Linus Torvalds [this message]
2009-06-18 16:52 ` Turn off '-Wtransparent-union' by default Linus Torvalds
2009-06-18 17:41   ` Avoid "attribute 'warning': unknown attribute" warning Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0906180940490.16802@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).