Skip to contentSkip to conversation

deal with enum members without excessive PITA

PATCH In review Al Viro 3 participants 7 messages Jun 24, 2007 – Apr 25, 2008 Sparse checker

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 15/16 deal with enum members without excessive PITA

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.

---
 expression.c |    7 +++++++
 parse.c      |    1 +
 symbol.h     |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)
expression.c +7 -0
index cf076a9..a40ab2b 100644
@@ -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);
parse.c +1 -0
index cfbf190..4e8a18b 100644
@@ -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);
 
symbol.h +1 -1
index 157346d..2bde84d 100644
@@ -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 */
Signature · 1 line
1.5.0-rc2.GIT
#1 lore raw

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

maintainer
#2 lore raw

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

Quoted 16 lines · Thomas Schmid

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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Antwort: Re: [PATCH 15/16] deal with enum members without excessive PITA

[email protected] schrieb am 14.12.2007 01:18:21:

Quoted 1 line

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?

Quoted 2 lines

It should be trivial make a patch to add members to the parent symbol->symbol_list though.

Would you possibly?

Best regards
Thomas Schmid

maintainer
#4 lore raw
Quoted 1 line · Thomas Schmid

How about the idea, looping over the syms within global_scope?

I think that will work too.

Quoted 3 lines
Quoted 2 lines
Quoted 1 line

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

#5 lore raw

Antwort: Re: Re: [PATCH 15/16] deal with enum members without excessive PITA

[email protected] schrieb am 14.12.2007 22:01:03:

Quoted 4 lines

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

#6 lore raw
In reply to Christopher Li

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

[email protected] schrieb am 14.12.2007 22:01:03:

Quoted 14 lines
Quoted 1 line · Thomas Schmid

How about the idea, looping over the syms within global_scope?

I think that will work too.

Quoted 3 lines
Quoted 2 lines
Quoted 1 line

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