* [PATCH 15/16] deal with enum members without excessive PITA
@ 2007-06-24 8:05 Al Viro
2007-12-13 14:21 ` Thomas Schmid
0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2007-06-24 8:05 UTC (permalink / raw)
To: linux-sparse
mark symbols for enum members, have primary_expression() copy their
->initializer instead of dancing through the EXRP_SYMBOL with
expand_expression() finally getting to the damn thing.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
expression.c | 7 +++++++
parse.c | 1 +
symbol.h | 2 +-
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/expression.c b/expression.c
index cf076a9..a40ab2b 100644
--- a/expression.c
+++ b/expression.c
@@ -359,6 +359,13 @@ struct token *primary_expression(struct token *token, struct expression **tree)
token = builtin_types_compatible_p_expr(token, &expr);
break;
}
+ } else if (sym->enum_member) {
+ expr = alloc_expression(token->pos, EXPR_VALUE);
+ *expr = *sym->initializer;
+ /* we want the right position reported, thus the copy */
+ expr->pos = token->pos;
+ token = next;
+ break;
}
expr = alloc_expression(token->pos, EXPR_SYMBOL);
diff --git a/parse.c b/parse.c
index cfbf190..4e8a18b 100644
--- a/parse.c
+++ b/parse.c
@@ -667,6 +667,7 @@ static struct token *parse_enum_declaration(struct token *token, struct symbol *
}
sym->initializer = expr;
+ sym->enum_member = 1;
sym->ctype.base_type = parent;
add_ptr_list(&entries, sym);
diff --git a/symbol.h b/symbol.h
index 157346d..2bde84d 100644
--- a/symbol.h
+++ b/symbol.h
@@ -109,7 +109,7 @@ extern int expand_constant_p(struct expression *expr, int cost);
struct symbol {
enum type type:8;
enum namespace namespace:9;
- unsigned char used:1, attr:2;
+ unsigned char used:1, attr:2, enum_member:1;
struct position pos; /* Where this symbol was declared */
struct ident *ident; /* What identifier this symbol is associated with */
struct symbol *next_id; /* Next semantic symbol that shares this identifier */
--
1.5.0-rc2.GIT
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-06-24 8:05 [PATCH 15/16] deal with enum members without excessive PITA Al Viro
@ 2007-12-13 14:21 ` Thomas Schmid
2007-12-14 0:18 ` Christopher Li
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Schmid @ 2007-12-13 14:21 UTC (permalink / raw)
To: Al Viro; +Cc: linux-sparse, linux-sparse-owner
Hello Al,
I just saw your patch for enum members, really late, I know.
But i've got a question: If I've got the symbol for a global enum - how do
I get from this to the symbols for the enum members?
If there is no way, I've got to loop over all symbols within global_scope,
right?
Best regards
Thomas Schmid
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-12-13 14:21 ` Thomas Schmid
@ 2007-12-14 0:18 ` Christopher Li
2007-12-14 12:09 ` Antwort: " Thomas Schmid
0 siblings, 1 reply; 7+ messages in thread
From: Christopher Li @ 2007-12-14 0:18 UTC (permalink / raw)
To: Thomas Schmid; +Cc: Al Viro, linux-sparse
It seems there is not good way to get the enum members from the parent symbol.
It should be trivial make a patch to add members to the parent
symbol->symbol_list though.
Chris
On Dec 13, 2007 6:21 AM, Thomas Schmid <Thomas.Schmid@br-automation.com> wrote:
> Hello Al,
>
> I just saw your patch for enum members, really late, I know.
>
> But i've got a question: If I've got the symbol for a global enum - how do
> I get from this to the symbols for the enum members?
> If there is no way, I've got to loop over all symbols within global_scope,
> right?
>
> Best regards
> Thomas Schmid
> -
> 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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Antwort: Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-12-14 0:18 ` Christopher Li
@ 2007-12-14 12:09 ` Thomas Schmid
2007-12-14 21:01 ` Christopher Li
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Schmid @ 2007-12-14 12:09 UTC (permalink / raw)
To: Christopher Li; +Cc: linux-sparse
linux-sparse-owner@vger.kernel.org schrieb am 14.12.2007 01:18:21:
> It seems there is not good way to get the enum members from the parent
symbol.
How about the idea, looping over the syms within global_scope?
> It should be trivial make a patch to add members to the parent
> symbol->symbol_list though.
Would you possibly?
Best regards
Thomas Schmid
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-12-14 12:09 ` Antwort: " Thomas Schmid
@ 2007-12-14 21:01 ` Christopher Li
2007-12-17 13:15 ` Antwort: " Thomas Schmid
2008-04-25 5:27 ` Thomas Schmid
0 siblings, 2 replies; 7+ messages in thread
From: Christopher Li @ 2007-12-14 21:01 UTC (permalink / raw)
To: Thomas Schmid; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 338 bytes --]
On Dec 14, 2007 4:09 AM, Thomas Schmid <Thomas.Schmid@br-automation.com> wrote:
> How about the idea, looping over the syms within global_scope?
I think that will work too.
> > > It should be trivial make a patch to add members to the parent
> > symbol->symbol_list though.
> Would you possibly?
Can you try the attached patch?
Chris
[-- Attachment #2: enum-members --]
[-- Type: application/octet-stream, Size: 1171 bytes --]
Add enum member list to the parent
Signed-Off-By: Christopher Li <sparse@chrisli.org>
Index: sparse/parse.c
===================================================================
--- sparse.orig/parse.c 2007-12-14 12:33:05.000000000 -0800
+++ sparse/parse.c 2007-12-14 12:42:39.000000000 -0800
@@ -651,7 +651,6 @@ static struct token *parse_enum_declarat
unsigned long long lastval = 0;
struct symbol *ctype = NULL, *base_type = NULL;
Num upper = {-1, 0}, lower = {1, 0};
- struct symbol_list *entries = NULL;
parent->examined = 1;
parent->ctype.base_type = &int_ctype;
@@ -687,7 +686,7 @@ static struct token *parse_enum_declarat
sym->initializer = expr;
sym->enum_member = 1;
sym->ctype.base_type = parent;
- add_ptr_list(&entries, sym);
+ add_ptr_list(&parent->symbol_list, sym);
if (base_type != &bad_ctype) {
if (ctype->type == SYM_NODE)
@@ -763,8 +762,7 @@ static struct token *parse_enum_declarat
parent->ctype.modifiers |= (base_type->ctype.modifiers & MOD_UNSIGNED);
parent->examined = 0;
- cast_enum_list(entries, base_type);
- free_ptr_list(&entries);
+ cast_enum_list(parent->symbol_list, base_type);
return token;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Antwort: Re: Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-12-14 21:01 ` Christopher Li
@ 2007-12-17 13:15 ` Thomas Schmid
2008-04-25 5:27 ` Thomas Schmid
1 sibling, 0 replies; 7+ messages in thread
From: Thomas Schmid @ 2007-12-17 13:15 UTC (permalink / raw)
To: Christopher Li; +Cc: linux-sparse
christ.li@gmail.com schrieb am 14.12.2007 22:01:03:
> Can you try the attached patch?
>
> Chris
> [Anhang "enum-members" gelöscht von Thomas Schmid/Graz/AT/B&R]
Thank you very much, works like expected!
What's the procedure to get this patch into the git-tree?
Best regards,
Thomas Schmid
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: Re: [PATCH 15/16] deal with enum members without excessive PITA
2007-12-14 21:01 ` Christopher Li
2007-12-17 13:15 ` Antwort: " Thomas Schmid
@ 2008-04-25 5:27 ` Thomas Schmid
1 sibling, 0 replies; 7+ messages in thread
From: Thomas Schmid @ 2008-04-25 5:27 UTC (permalink / raw)
To: Josh Triplett; +Cc: linux-sparse, linux-sparse-owner, Christopher Li
[-- Attachment #1: Type: text/plain, Size: 644 bytes --]
Hello Josh,
Christopger Li sent this patch 4 month ago and i'd appreciate to see this
patch applied.
I added an "Acked-by" to the patch.
Enum-members will now be stored in symbol->symbol_list.
Thanks,
Tom
linux-sparse-owner@vger.kernel.org schrieb am 14.12.2007 22:01:03:
> On Dec 14, 2007 4:09 AM, Thomas Schmid <Thomas.Schmid@br-automation.
> com> wrote:
> > How about the idea, looping over the syms within global_scope?
>
> I think that will work too.
>
> > > > It should be trivial make a patch to add members to the parent
> > > symbol->symbol_list though.
> > Would you possibly?
>
> Can you try the attached patch?
>
> Chris
>
[-- Attachment #2: enum-members --]
[-- Type: application/octet-stream, Size: 1230 bytes --]
Add enum member list to the parent
Signed-Off-By: Christopher Li <sparse@chrisli.org>
Acked-by: Thomas Schmid <Thomas.Schmid@br-automation.com>
Index: sparse/parse.c
===================================================================
--- sparse.orig/parse.c 2007-12-14 12:33:05.000000000 -0800
+++ sparse/parse.c 2007-12-14 12:42:39.000000000 -0800
@@ -651,7 +651,6 @@ static struct token *parse_enum_declarat
unsigned long long lastval = 0;
struct symbol *ctype = NULL, *base_type = NULL;
Num upper = {-1, 0}, lower = {1, 0};
- struct symbol_list *entries = NULL;
parent->examined = 1;
parent->ctype.base_type = &int_ctype;
@@ -687,7 +686,7 @@ static struct token *parse_enum_declarat
sym->initializer = expr;
sym->enum_member = 1;
sym->ctype.base_type = parent;
- add_ptr_list(&entries, sym);
+ add_ptr_list(&parent->symbol_list, sym);
if (base_type != &bad_ctype) {
if (ctype->type == SYM_NODE)
@@ -763,8 +762,7 @@ static struct token *parse_enum_declarat
parent->ctype.modifiers |= (base_type->ctype.modifiers & MOD_UNSIGNED);
parent->examined = 0;
- cast_enum_list(entries, base_type);
- free_ptr_list(&entries);
+ cast_enum_list(parent->symbol_list, base_type);
return token;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-04-25 5:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-24 8:05 [PATCH 15/16] deal with enum members without excessive PITA Al Viro
2007-12-13 14:21 ` Thomas Schmid
2007-12-14 0:18 ` Christopher Li
2007-12-14 12:09 ` Antwort: " Thomas Schmid
2007-12-14 21:01 ` Christopher Li
2007-12-17 13:15 ` Antwort: " Thomas Schmid
2008-04-25 5:27 ` Thomas Schmid
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.