From 6fc5b32123e1c1baf2a1af3cc5edd95153e34756 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Sun, 27 Jan 2013 13:03:02 +0000 Subject: [PATCH] Fix warning, and better tests for __VA_ARGS__ --- ftepp.c | 2 +- tests/pp_va_args.qc | 21 +++++++++++++++------ tests/pp_va_args.tmpl | 7 ++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ftepp.c b/ftepp.c index b269757..b695edc 100644 --- a/ftepp.c +++ b/ftepp.c @@ -720,7 +720,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param break; case TOKEN_VA_ARGS_ARRAY: - if (out->constval.i >= varargs) { + if ((size_t)out->constval.i >= varargs) { ftepp_error(ftepp, "subscript of `[%u]` is out of bounds for `__VA_ARGS__`", out->constval.i); vec_free(old_string); return false; diff --git a/tests/pp_va_args.qc b/tests/pp_va_args.qc index f54533b..6e4002c 100644 --- a/tests/pp_va_args.qc +++ b/tests/pp_va_args.qc @@ -1,12 +1,21 @@ void print(...) = #1; -#define NOPARENS(...) __VA_ARGS__ -#define callem(func, args) func NOPARENS(args) +// method 0 +#define METHOD__(...) __VA_ARGS__ +#define METHOD_0(F,A) F METHOD__(A) -#define callen(func, ...) func __VA_ARGS__##[0] +// method 1 +#define METHOD_1(F,A) F(METHOD__ A) + +// method 2 +#define METHOD_2(F,...) F __VA_ARGS__##[0] + +// method 3 +#define METHOD_3(F,...) F __VA_ARGS__ void main() { - print(NOPARENS("hello ", "world\n")); - callem(print, ("Yay", ", there\n")); - callen(print, ("Woah",", there\n")); + METHOD_0(print, ("Method", " \n")); + METHOD_1(print, ("Method", " \n")); + METHOD_2(print, ("Method", " \n")); + METHOD_3(print, ("Method", " \n")); } diff --git a/tests/pp_va_args.tmpl b/tests/pp_va_args.tmpl index c6e0c14..b3f30f6 100644 --- a/tests/pp_va_args.tmpl +++ b/tests/pp_va_args.tmpl @@ -2,6 +2,7 @@ I: pp_va_args.qc D: __VA_ARGS__ T: -execute C: -std=fteqcc -M: hello world -M: Yay, there -M: Woah, there +M: Method +M: Method +M: Method +M: Method -- 2.39.2