aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2009-03-21 17:28:23 +0000
committerChristopher Li <sparse@chrisli.org>2009-07-18 05:30:10 +0000
commit48a736d62137f7c25e7186529f04244229c75d22 (patch)
tree85b131a7853b30614f9ed4d35532fe93c0138ae5
parentf7e7d7cbad5b04136abbfed66726d99dd84af526 (diff)
downloadsparse-48a736d62137f7c25e7186529f04244229c75d22.tar.gz
warn directive in argument list
On Sat, Mar 21, 2009 at 04:40:20AM +0000, Al Viro wrote: > > Well... patch below would give more or less close approximation to the > current set of nasal demons produced by gcc in these situations + error > when that crap happens. > Warning: it might make things slower, and it needs testing. > > --- It needed testing, all right - #elif handling got broken by the initial variant... Hopefully fixed version follows: Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--pre-process.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/pre-process.c b/pre-process.c
index cf538930..34b21ff0 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -193,13 +193,36 @@ static void expand_list(struct token **list)
}
}
+static void preprocessor_line(struct stream *stream, struct token **line);
+
static struct token *collect_arg(struct token *prev, int vararg, struct position *pos)
{
+ struct stream *stream = input_streams + prev->pos.stream;
struct token **p = &prev->next;
struct token *next;
int nesting = 0;
while (!eof_token(next = scan_next(p))) {
+ if (next->pos.newline && match_op(next, '#')) {
+ if (!next->pos.noexpand) {
+ sparse_error(next->pos,
+ "directive in argument list");
+ preprocessor_line(stream, p);
+ __free_token(next); /* Free the '#' token */
+ continue;
+ }
+ }
+ switch (token_type(next)) {
+ case TOKEN_STREAMEND:
+ case TOKEN_STREAMBEGIN:
+ *p = &eof_token_entry;
+ return next;
+ }
+ if (false_nesting) {
+ *p = next->next;
+ __free_token(next);
+ continue;
+ }
if (match_op(next, '(')) {
nesting++;
} else if (match_op(next, ')')) {
@@ -1357,8 +1380,9 @@ static int handle_elif(struct stream * stream, struct token **line, struct token
if (token_type(top_if) != TOKEN_IF)
return 1;
if (false_nesting) {
- if (expression_value(&token->next))
- false_nesting = 0;
+ false_nesting = 0;
+ if (!expression_value(&token->next))
+ false_nesting = 1;
} else {
false_nesting = 1;
token_type(top_if) = TOKEN_SKIP_GROUPS;