From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 15/16] deal with enum members without excessive PITA
Date: Sun, 24 Jun 2007 09:05:41 +0100 [thread overview]
Message-ID: <E1I2N6L-0003fT-82@ZenIV.linux.org.uk> (raw)
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
next reply other threads:[~2007-06-24 8:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-24 8:05 Al Viro [this message]
2007-12-13 14:21 ` [PATCH 15/16] deal with enum members without excessive PITA 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
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=E1I2N6L-0003fT-82@ZenIV.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-sparse@vger.kernel.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).