linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Li <sparse@chrisli.org>
To: Michael Stefaniuc <mstefani@redhat.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: Ignore the ms_abi/sysv_abi attributes.
Date: Tue, 29 Sep 2009 16:30:11 -0700	[thread overview]
Message-ID: <70318cbf0909291630q73f92ab9ma980ca98564f366f@mail.gmail.com> (raw)
In-Reply-To: <20090929210106.GA3592@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

On Tue, Sep 29, 2009 at 2:01 PM, Michael Stefaniuc <mstefani@redhat.com> wrote:
> This is needed for getting a meaningful sparse run on a Wine 64-bit
> compile. Else the basic Win32 headers will produce tons of
> error: attribute 'ms_abi': unknown attribute
> which end in
> error: too many errors.
>
> The sysv_abi attribute was just added for symmetry.

Thanks for the patch. Ignoring the attribute has become so common now.
I decide stop the complicate way to adding ignored attributes.

I attach two patches to simplify things. I am I am going to push
them out to chrisl tree.

Can you change your patch base on my new patch?

It should be really simple, just add one string for each attribute
is good enough.

Thanks!

Chris

[-- Attachment #2: 0001-Move-noreturn-attribute-out-of-ignore-attr-area.patch --]
[-- Type: application/octet-stream, Size: 1419 bytes --]

From b0baf9ed31ef756734331cf9b8a9ab377e93d316 Mon Sep 17 00:00:00 2001
From: Christopher Li <sparse@chrisli.org>
Date: Tue, 29 Sep 2009 14:58:48 -0700
Subject: [PATCH] Move noreturn attribute out of ignore attr area

Signed-off-by: Christopher Li <sparse@chrisli.org>
---
 parse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/parse.c b/parse.c
index 90403d8..b3bf15d 100644
--- a/parse.c
+++ b/parse.c
@@ -454,6 +454,8 @@ static struct init_keyword {
 	{ "mode",	NS_KEYWORD,	.op = &mode_op },
 	{ "context",	NS_KEYWORD,	.op = &context_op },
 	{ "__transparent_union__",	NS_KEYWORD,	.op = &transparent_union_op },
+	{ "noreturn",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
+	{ "__noreturn__",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
 
 	{ "__mode__",	NS_KEYWORD,	.op = &mode_op },
 	{ "QI",		NS_KEYWORD,	MOD_CHAR,	.op = &mode_QI_op },
@@ -489,8 +491,6 @@ static struct init_keyword {
 	{ "const",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__const",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__const__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "noreturn",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
-	{ "__noreturn__",	NS_KEYWORD,	MOD_NORETURN,	.op = &attr_mod_op },
 	{ "no_instrument_function",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "__no_instrument_function__",	NS_KEYWORD,	.op = &ignore_attr_op },
 	{ "sentinel",	NS_KEYWORD,	.op = &ignore_attr_op },
-- 
1.6.0.6


[-- Attachment #3: 0002-Declare-ignored-attributres-into-a-list-of-string.patch --]
[-- Type: application/octet-stream, Size: 6973 bytes --]

From dc9f14bd8cca5023f3ea07f2f3969737d9448c6a Mon Sep 17 00:00:00 2001
From: Christopher Li <sparse@chrisli.org>
Date: Tue, 29 Sep 2009 16:17:23 -0700
Subject: [PATCH] Declare ignored attributres into a list of string.

Adding ignored attributes is much easier now.

Signed-off-by: Christopher Li <sparse@chrisli.org>
---
 lib.h   |    4 ++
 parse.c |  153 ++++++++++++++++++++++++++++++++++-----------------------------
 2 files changed, 86 insertions(+), 71 deletions(-)

diff --git a/lib.h b/lib.h
index 25abb80..e19973f 100644
--- a/lib.h
+++ b/lib.h
@@ -20,6 +20,10 @@
 #define DO_STRINGIFY(x) #x
 #define STRINGIFY(x) DO_STRINGIFY(x)
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
+#endif
+
 extern int verbose, optimize, optimize_size, preprocessing;
 extern int die_if_error;
 extern int repeat_phase, merge_phi_sources;
diff --git a/parse.c b/parse.c
index b3bf15d..34fa562 100644
--- a/parse.c
+++ b/parse.c
@@ -470,83 +470,85 @@ static struct init_keyword {
 	{ "__TI__",	NS_KEYWORD,	MOD_LONGLONGLONG,	.op = &mode_TI_op },
 	{ "word",	NS_KEYWORD,	MOD_LONG,	.op = &mode_word_op },
 	{ "__word__",	NS_KEYWORD,	MOD_LONG,	.op = &mode_word_op },
+};
 
-	/* Ignored attributes */
-	{ "nothrow",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__nothrow",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__nothrow__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "malloc",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__malloc__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "nonnull",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__nonnull",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__nonnull__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "format",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__format__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "format_arg",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__format_arg__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "section",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__section__",NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "unused",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__unused__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "const",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__const",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__const__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "no_instrument_function",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__no_instrument_function__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "sentinel",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__sentinel__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "regparm",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__regparm__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "weak",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__weak__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "alias",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__alias__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "pure",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__pure__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "always_inline",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__always_inline__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "syscall_linkage",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__syscall_linkage__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "visibility",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__visibility__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "deprecated",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__deprecated__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "noinline",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__noinline__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "used",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__used__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "warn_unused_result",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__warn_unused_result__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "model",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__model__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "cdecl",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__cdecl__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "stdcall",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__stdcall__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "fastcall",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__fastcall__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "dllimport",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__dllimport__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "dllexport",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__dllexport__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "constructor",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__constructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "destructor",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__destructor__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "cold",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__cold__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "hot",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__hot__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "warning",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__warning__",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "bounded",	NS_KEYWORD,	.op = &ignore_attr_op },
-	{ "__bounded__",	NS_KEYWORD,	.op = &ignore_attr_op },
+const char *ignored_attributes[] = {
+	"alias",
+	"__alias__",
+	"always_inline",
+	"__always_inline__",
+	"bounded",
+	"__bounded__",
+	"cdecl",
+	"__cdecl__",
+	"cold",
+	"__cold__",
+	"const",
+	"__const",
+	"__const__",
+	"constructor",
+	"__constructor__",
+	"deprecated",
+	"__deprecated__",
+	"destructor",
+	"__destructor__",
+	"dllexport",
+	"__dllexport__",
+	"dllimport",
+	"__dllimport__",
+	"fastcall",
+	"__fastcall__",
+	"format",
+	"__format__",
+	"format_arg",
+	"__format_arg__",
+	"hot",
+	"__hot__",
+	"malloc",
+	"__malloc__",
+	"model",
+	"__model__",
+	"no_instrument_function",
+	"__no_instrument_function__",
+	"noinline",
+	"__noinline__",
+	"nonnull",
+	"__nonnull",
+	"__nonnull__",
+	"nothrow",
+	"__nothrow",
+	"__nothrow__",
+	"pure",
+	"__pure__",
+	"regparm",
+	"__regparm__",
+	"section",
+	"__section__",
+	"sentinel",
+	"__sentinel__",
+	"stdcall",
+	"__stdcall__",
+	"syscall_linkage",
+	"__syscall_linkage__",
+	"unused",
+	"__unused__",
+	"used",
+	"__used__",
+	"visibility",
+	"__visibility__",
+	"warn_unused_result",
+	"__warn_unused_result__",
+	"warning",
+	"__warning__",
+	"weak",
+	"__weak__",
 };
 
+
 void init_parser(int stream)
 {
 	int i;
-	for (i = 0; i < sizeof keyword_table/sizeof keyword_table[0]; i++) {
+	for (i = 0; i < ARRAY_SIZE(keyword_table); i++) {
 		struct init_keyword *ptr = keyword_table + i;
 		struct symbol *sym = create_symbol(stream, ptr->name, SYM_KEYWORD, ptr->ns);
 		sym->ident->keyword = 1;
@@ -556,8 +558,17 @@ void init_parser(int stream)
 		sym->ctype.base_type = ptr->type;
 		sym->op = ptr->op;
 	}
+
+	for (i = 0; i < ARRAY_SIZE(ignored_attributes); i++) {
+		const char * name = ignored_attributes[i];
+		struct symbol *sym = create_symbol(stream, name, SYM_KEYWORD,
+						   NS_KEYWORD);
+		sym->ident->keyword = 1;
+		sym->op = &ignore_attr_op;
+	}
 }
 
+
 // Add a symbol to the list of function-local symbols
 static void fn_local_symbol(struct symbol *sym)
 {
-- 
1.6.0.6


  reply	other threads:[~2009-09-29 23:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29 21:01 Ignore the ms_abi/sysv_abi attributes Michael Stefaniuc
2009-09-29 23:30 ` Christopher Li [this message]
2009-09-30 20:21   ` Michael Stefaniuc
2009-09-30 20:49     ` Christopher Li

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=70318cbf0909291630q73f92ab9ma980ca98564f366f@mail.gmail.com \
    --to=sparse@chrisli.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=mstefani@redhat.com \
    /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).