aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-09 10:46:46 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:04:13 -0700
commit0161959ea82413d3e66f009b3c3042ad51f4f884 (patch)
treee7f2d65ea31941a2e3a5d6ca5692d1dde0d83345 /pre-process.c
parentPrettier debug printout - fix missing \n (diff)
downloadsparse-0161959ea82413d3e66f009b3c3042ad51f4f884.tar.gz
sparse-0161959ea82413d3e66f009b3c3042ad51f4f884.tar.bz2
sparse-0161959ea82413d3e66f009b3c3042ad51f4f884.zip
Honor pre-processor conditionals even when they don't match within a stream.
We still warn about them, but we act as if it was ok. The "vik2" IOCCC-2004 entry does some nasty preprocessor stuff on purpose. We parse it all right, but because we refused to honor #if statements that are terminated in another stream, we didn't get the output Daniel Vik intended.
Diffstat (limited to 'pre-process.c')
-rw-r--r--pre-process.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/pre-process.c b/pre-process.c
index e9103c6..d48b52f 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1187,10 +1187,8 @@ static int handle_elif(struct stream * stream, struct token **line, struct token
if (stream->nesting == if_nesting)
MARK_STREAM_NONCONST(token->pos);
- if (stream->nesting > if_nesting) {
- warning(token->pos, "unmatched #elif");
- return 1;
- }
+ if (stream->nesting > if_nesting)
+ warning(token->pos, "unmatched #elif within stream");
if (elif_ignore[if_nesting-1] & ELIF_SEEN_ELSE)
warning(token->pos, "#elif after #else");
@@ -1216,10 +1214,8 @@ static int handle_else(struct stream *stream, struct token **line, struct token
if (stream->nesting == if_nesting)
MARK_STREAM_NONCONST(token->pos);
- if (stream->nesting > if_nesting) {
- warning(token->pos, "unmatched #else");
- return 1;
- }
+ if (stream->nesting > if_nesting)
+ warning(token->pos, "unmatched #else within stream");
if (elif_ignore[if_nesting-1] & ELIF_SEEN_ELSE)
warning(token->pos, "#else after #else");
@@ -1246,8 +1242,8 @@ static int handle_endif(struct stream *stream, struct token **line, struct token
stream->constant = CONSTANT_FILE_MAYBE;
if (stream->nesting > if_nesting)
- warning(token->pos, "unmatched #endif");
- else if (false_nesting)
+ warning(token->pos, "unmatched #endif in stream");
+ if (false_nesting)
false_nesting--;
else
true_nesting--;