aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--pre-process.c3
-rw-r--r--validation/preprocessor/expand-redef.c20
2 files changed, 22 insertions, 1 deletions
diff --git a/pre-process.c b/pre-process.c
index f2053676..c8725dc8 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -760,6 +760,7 @@ static int expand(struct token **list, struct symbol *sym)
struct token *token = *list;
struct ident *expanding = token->ident;
struct token **tail;
+ struct token *expansion = sym->expansion;
int nargs = sym->arglist ? sym->arglist->count.normal : 0;
struct arg args[nargs];
@@ -779,7 +780,7 @@ static int expand(struct token **list, struct symbol *sym)
expanding->tainted = 1;
last = token->next;
- tail = substitute(list, sym->expansion, args);
+ tail = substitute(list, expansion, args);
/*
* Note that it won't be eof - at least TOKEN_UNTAINT will be there.
* We still can lose the newline flag if the sucker expands to nothing,
diff --git a/validation/preprocessor/expand-redef.c b/validation/preprocessor/expand-redef.c
new file mode 100644
index 00000000..0ccf0d4c
--- /dev/null
+++ b/validation/preprocessor/expand-redef.c
@@ -0,0 +1,20 @@
+#define f(x) x x
+f(1
+#undef f
+#define f 2
+ f)
+
+/*
+ * check-name: expand-redef
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+1 2 1 2
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/expand-redef.c:3:1: warning: directive in macro's argument list
+preprocessor/expand-redef.c:4:1: warning: directive in macro's argument list
+ * check-error-end
+ */