aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2005-11-27 17:53:14 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-27 17:40:51 -0800
commit8bab495ee7060d307872f0f13153422ccc543c03 (patch)
treee7daf6687100e378d0c49851ebd5b2f478079fc9 /token.h
parent[PATCH] lookup_macro() should be static (diff)
downloadsparse-8bab495ee7060d307872f0f13153422ccc543c03.tar.gz
sparse-8bab495ee7060d307872f0f13153422ccc543c03.tar.bz2
sparse-8bab495ee7060d307872f0f13153422ccc543c03.zip
[PATCH] eliminate elif_ignore, fix handling of unterminated #if
No need to bother with stack; we can just keep # tokens from #if... and use _those_ as a stack instead. struct stream gets a pointer to the current #if..., checks for #elif/#else/#endif out of place become simple if (!stream->top_if) and stream->ifndef becomes a pointer to token instead of an integer (pointer to token in that stack instead of nesting depth). We lose elif_ignore[] array, if_nesting and stream->nesting (nothing cares of those anymore) and get sane handling of unterminated #if for free - instead of reporting the location of the last #if on depth 0 (very likely - in another file and having an #endif) we can give location of the #if that really lacks #endif. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'token.h')
-rw-r--r--token.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/token.h b/token.h
index aff5bbc..96b0c41 100644
--- a/token.h
+++ b/token.h
@@ -40,10 +40,10 @@ struct stream {
/* Use these to check for "already parsed" */
enum constantfile constant;
- int nesting;
- int ifndef;
int dirty;
struct ident *protect;
+ struct token *ifndef;
+ struct token *top_if;
};
extern int input_stream_nr;
@@ -76,6 +76,9 @@ enum token_type {
TOKEN_GNU_KLUDGE,
TOKEN_UNTAINT,
TOKEN_ARG_COUNT,
+ TOKEN_IF,
+ TOKEN_SKIP_GROUPS,
+ TOKEN_ELSE,
};
/* Combination tokens */