From 6c468c10f70d74e962591a0584765e42ce1bcaf2 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 5 Jun 2017 13:21:39 +0200 Subject: tccpp: allow "#define X defined Y ..." That means: we do not macro-expand the argument of 'defined' Also: store the last token position into the TokenString structure in order to get rid of the tok_last function. --- tests/pp/21.c | 36 ++++++++++++++++++++++++++++++++++++ tests/pp/21.expect | 8 ++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/pp/21.c create mode 100644 tests/pp/21.expect (limited to 'tests') diff --git a/tests/pp/21.c b/tests/pp/21.c new file mode 100644 index 0000000..1316226 --- /dev/null +++ b/tests/pp/21.c @@ -0,0 +1,36 @@ +/* accept 'defined' as result of substitution */ + +----- 1 ------ +#define AAA 2 +#define BBB +#define CCC (defined ( AAA ) && AAA > 1 && !defined BBB) +#if !CCC +OK +#else +NOT OK +#endif + +----- 2 ------ +#undef BBB +#if CCC +OK +#else +NOT OK +#endif + +----- 3 ------ +#define DEFINED defined +#define DDD (DEFINED ( AAA ) && AAA > 1 && !DEFINED BBB) +#if (DDD) +OK +#else +NOT OK +#endif + +----- 4 ------ +#undef AAA +#if !(DDD) +OK +#else +NOT OK +#endif diff --git a/tests/pp/21.expect b/tests/pp/21.expect new file mode 100644 index 0000000..5a1376b --- /dev/null +++ b/tests/pp/21.expect @@ -0,0 +1,8 @@ +----- 1 ------ +OK +----- 2 ------ +OK +----- 3 ------ +OK +----- 4 ------ +OK -- cgit v1.3.1