From d0d25ec7df636deaf650d31ae3b50e60659f54dd Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 8 Aug 2016 22:26:11 +0200 Subject: tccpp: Allow computed include like 42.h The include directive needs to be parsed as pp-tokens, not as token (i.e. no conversion to TOK_STR or TOK_NUM). Also fix parsing computed includes using quoted strings. --- tests/tcctest.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/tcctest.c') diff --git a/tests/tcctest.c b/tests/tcctest.c index 52dbfaf..2abbacd 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -44,7 +44,7 @@ #define TCCLIB_INC #define TCCLIB_INC1 -#define TCCLIB_INC3 "tcclib" +#define TCCLIB_INC3 "tcclib.h" #include TCCLIB_INC @@ -52,8 +52,7 @@ #include TCCLIB_INC1.h> -/* gcc 3.2 does not accept that (bug ?) */ -//#include TCCLIB_INC3 ".h" +#include TCCLIB_INC3 #include @@ -61,6 +60,17 @@ #include "tcctest.h" +/* Test two more ways to include a file named like a pp-number */ +#define INC(name) +#define funnyname 42test.h +#define incdir tests/ +#define incname < incdir funnyname > +#define __stringify(x) #x +#define stringify(x) __stringify(x) +#include INC(42test) +#include incname +#include stringify(funnyname) + void intdiv_test(); void string_test(); void expr_test(); @@ -396,6 +406,11 @@ comment printf("%s\n", __BASE_FILE__); printf("%s\n", get_file_from_header()); printf("%s\n", __FILE__); + + /* Check that funnily named include was in fact included */ + have_included_42test_h = 1; + have_included_42test_h_second = 1; + have_included_42test_h_third = 1; } -- cgit v1.3.1