aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-01-02 22:20:21 +0300
committerJosh Triplett <josh@freedesktop.org>2006-12-05 03:08:58 -0800
commit3c083484a3594f3c4e72fc06c001418a67dfe71a (patch)
treec90b2526ca36e8db30a00ce8ea41bbe45e45e1ec /pre-process.c
parentprepare for #strong_{define,undef} (diff)
downloadsparse-3c083484a3594f3c4e72fc06c001418a67dfe71a.tar.gz
sparse-3c083484a3594f3c4e72fc06c001418a67dfe71a.tar.bz2
sparse-3c083484a3594f3c4e72fc06c001418a67dfe71a.zip
implement #strong_define
Example #strong_define FOO 1 #undef FOO // silently ignored #define FOO 2 // silently ignored This allows (for example) to override CONFIG_XXX values without editing include/linux/autoconf.h I think this is useful. If you think differently, I will appreciate your comments on this patch correctness. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Diffstat (limited to 'pre-process.c')
-rw-r--r--pre-process.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/pre-process.c b/pre-process.c
index 604b101..0fb7831 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1092,7 +1092,7 @@ static int do_handle_define(struct stream *stream, struct token **line, struct t
if (sym) {
int clean;
- if (attr > sym->attr)
+ if (attr < sym->attr)
goto out;
clean = (attr == sym->attr);
@@ -1138,6 +1138,11 @@ static int handle_weak_define(struct stream *stream, struct token **line, struct
return do_handle_define(stream, line, token, SYM_ATTR_WEAK);
}
+static int handle_strong_define(struct stream *stream, struct token **line, struct token *token)
+{
+ return do_handle_define(stream, line, token, SYM_ATTR_STRONG);
+}
+
static int handle_undef(struct stream *stream, struct token **line, struct token *token)
{
struct token *left = token->next;
@@ -1149,7 +1154,7 @@ static int handle_undef(struct stream *stream, struct token **line, struct token
}
sym = lookup_macro(left->ident);
- if (!sym)
+ if (!sym || sym->attr > SYM_ATTR_NORMAL)
return 1;
if (sym->scope != file_scope) {
@@ -1569,15 +1574,16 @@ static void init_preprocessor(void)
const char *name;
int (*handler)(struct stream *, struct token **, struct token *);
} normal[] = {
- { "define", handle_define },
- { "weak_define",handle_weak_define },
- { "undef", handle_undef },
- { "warning", handle_warning },
- { "error", handle_error },
- { "include", handle_include },
- { "include_next",handle_include_next },
- { "pragma", handle_pragma },
- { "line", handle_line },
+ { "define", handle_define },
+ { "weak_define", handle_weak_define },
+ { "strong_define", handle_strong_define },
+ { "undef", handle_undef },
+ { "warning", handle_warning },
+ { "error", handle_error },
+ { "include", handle_include },
+ { "include_next", handle_include_next },
+ { "pragma", handle_pragma },
+ { "line", handle_line },
// our internal preprocessor tokens
{ "nostdinc", handle_nostdinc },