diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-11-05 14:37:38 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:04:01 -0700 |
| commit | 15fd7348463522c6089350e1adb778acd501ddf4 (patch) | |
| tree | 0185d79ed05a545b156cbbdd52260bcdf63b6074 /pre-process.c | |
| parent | 0970f9e7d36a9c7c6c5693e559d4bcb3e001ece6 (diff) | |
| download | sparse-dev-15fd7348463522c6089350e1adb778acd501ddf4.tar.gz | |
Using a preprocessor symbol makes it non-weak.
This causes us to warn if somebody tries to re-define a
symbol that has already been used, even if it was originally
non-weak.
Noted by Morten Welinder
Diffstat (limited to 'pre-process.c')
| -rw-r--r-- | pre-process.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pre-process.c b/pre-process.c index 16851c0f..e9103c6d 100644 --- a/pre-process.c +++ b/pre-process.c @@ -95,8 +95,14 @@ static void replace_with_integer(struct token *token, unsigned int val) static int token_defined(struct token *token) { - if (token_type(token) == TOKEN_IDENT) - return lookup_symbol(token->ident, NS_MACRO) != NULL; + if (token_type(token) == TOKEN_IDENT) { + struct symbol *sym = lookup_symbol(token->ident, NS_MACRO); + if (sym) { + sym->weak = 0; + return 1; + } + return 0; + } warning(token->pos, "expected preprocessor identifier"); return 0; @@ -120,8 +126,10 @@ static int expand_one_symbol(struct token **list) return 1; sym = lookup_symbol(token->ident, NS_MACRO); - if (sym) + if (sym) { + sym->weak = 0; return expand(list, sym); + } if (token->ident == &__LINE___ident) { replace_with_integer(token, token->pos.line); } else if (token->ident == &__FILE___ident) { |
