All of lore.kernel.org
 help / color / mirror / Atom feed
* __attribute__ annotations and struct types
@ 2007-02-14 20:01 Daniel Drake
  2007-02-14 20:15 ` [PATCH] " Christopher Li
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Drake @ 2007-02-14 20:01 UTC (permalink / raw)
  To: linux-sparse

gcc-4.1.1 accepts this as valid code:

struct __attribute__((__aligned__(16))) foo {
    int a;
};

sparse doesn't like it:

	test.c:7:8: error: Trying to use reserved word '__attribute__' 
	as identifier

I'm not sure if this is a bug that people are interested in solving, as
the more common form works in both gcc and sparse:

struct foo {
    int a;
} __attribute__((__aligned__(16)));

Thanks,
-- 
Daniel Drake
Brontes Technologies, A 3M Company

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Re: __attribute__ annotations and struct types
  2007-02-14 20:01 __attribute__ annotations and struct types Daniel Drake
@ 2007-02-14 20:15 ` Christopher Li
  2007-02-14 21:02   ` Daniel Drake
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Li @ 2007-02-14 20:15 UTC (permalink / raw)
  To: Daniel Drake; +Cc: linux-sparse, Josh Triplett

On Wed, Feb 14, 2007 at 03:01:54PM -0500, Daniel Drake wrote:
> sparse doesn't like it:
> 
> 	test.c:7:8: error: Trying to use reserved word '__attribute__' 
> 	as identifier

Can you please try this:

Chris

Handle structure attribute.

struct __attribute__((__aligned__(16))) foo {
    int a;
};

Signed-Off-By: Christopher Li <sparse@chrisli.org>

Index: sparse/parse.c
===================================================================
--- sparse.orig/parse.c	2007-02-14 12:37:17.000000000 -0800
+++ sparse/parse.c	2007-02-14 12:40:48.000000000 -0800
@@ -34,6 +34,7 @@ struct symbol_list *function_computed_ta
 struct statement_list *function_computed_goto_list;
 
 static struct token *statement(struct token *token, struct statement **tree);
+static struct token *handle_attributes(struct token *token, struct ctype *ctype);
 
 // Add a symbol to the list of function-local symbols
 static void fn_local_symbol(struct symbol *sym)
@@ -156,6 +157,7 @@ static struct token *struct_union_enum_s
 	struct position *repos;
 
 	ctype->modifiers = 0;
+	token = handle_attributes(token, ctype);
 	if (token_type(token) == TOKEN_IDENT) {
 		sym = lookup_symbol(token->ident, NS_STRUCT);
 		if (!sym ||

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Re: __attribute__ annotations and struct types
  2007-02-14 20:15 ` [PATCH] " Christopher Li
@ 2007-02-14 21:02   ` Daniel Drake
  2007-02-14 21:05     ` Randy Dunlap
  2007-02-23  2:23     ` Josh Triplett
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Drake @ 2007-02-14 21:02 UTC (permalink / raw)
  To: Christopher Li; +Cc: linux-sparse, Josh Triplett

On Wed, 2007-02-14 at 12:15 -0800, Christopher Li wrote:
> On Wed, Feb 14, 2007 at 03:01:54PM -0500, Daniel Drake wrote:
> > sparse doesn't like it:
> > 
> > 	test.c:7:8: error: Trying to use reserved word '__attribute__' 
> > 	as identifier
> 
> Can you please try this:
> 
> Chris
> 
> Handle structure attribute.

Thanks for the quick response, works nicely!

-- 
Daniel Drake
Brontes Technologies, A 3M Company

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Re: __attribute__ annotations and struct types
  2007-02-14 21:02   ` Daniel Drake
@ 2007-02-14 21:05     ` Randy Dunlap
  2007-02-23  2:23     ` Josh Triplett
  1 sibling, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2007-02-14 21:05 UTC (permalink / raw)
  To: Daniel Drake; +Cc: Christopher Li, linux-sparse, Josh Triplett

On Wed, 14 Feb 2007 16:02:07 -0500 Daniel Drake wrote:

> On Wed, 2007-02-14 at 12:15 -0800, Christopher Li wrote:
> > On Wed, Feb 14, 2007 at 03:01:54PM -0500, Daniel Drake wrote:
> > > sparse doesn't like it:
> > > 
> > > 	test.c:7:8: error: Trying to use reserved word '__attribute__' 
> > > 	as identifier
> > 
> > Can you please try this:
> > 
> > Chris
> > 
> > Handle structure attribute.
> 
> Thanks for the quick response, works nicely!

so now drivers/kvm/* should be less nasty  ;)

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Re: __attribute__ annotations and struct types
  2007-02-14 21:02   ` Daniel Drake
  2007-02-14 21:05     ` Randy Dunlap
@ 2007-02-23  2:23     ` Josh Triplett
  1 sibling, 0 replies; 5+ messages in thread
From: Josh Triplett @ 2007-02-23  2:23 UTC (permalink / raw)
  To: Daniel Drake; +Cc: Christopher Li, linux-sparse

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

Daniel Drake wrote:
> On Wed, 2007-02-14 at 12:15 -0800, Christopher Li wrote:
>> On Wed, Feb 14, 2007 at 03:01:54PM -0500, Daniel Drake wrote:
>>> sparse doesn't like it:
>>>
>>> 	test.c:7:8: error: Trying to use reserved word '__attribute__' 
>>> 	as identifier
>> Can you please try this:
>>
>> Chris
>>
>> Handle structure attribute.
> 
> Thanks for the quick response, works nicely!

Applied, along with a test case.

- Josh Triplett



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-02-23  2:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 20:01 __attribute__ annotations and struct types Daniel Drake
2007-02-14 20:15 ` [PATCH] " Christopher Li
2007-02-14 21:02   ` Daniel Drake
2007-02-14 21:05     ` Randy Dunlap
2007-02-23  2:23     ` Josh Triplett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.