aboutsummaryrefslogtreecommitdiff
path: root/tests/tcctest.c
diff options
context:
space:
mode:
authorJoe Soroka <gits@joesoroka.com>2011-02-01 13:23:40 -0800
committerJoe Soroka <gits@joesoroka.com>2011-02-01 13:23:40 -0800
commit75c6695932b55b914f16b20dc32ff3ef1203ed4b (patch)
treece7a5642124f1be01525eacb5cff8baddaf5629e /tests/tcctest.c
parentcf08675702044c180553c866ba1fde0414f00590 (diff)
downloadtinycc-75c6695932b55b914f16b20dc32ff3ef1203ed4b.tar.gz
tinycc-75c6695932b55b914f16b20dc32ff3ef1203ed4b.tar.bz2
tccpp: fix bug in handling of recursive macros
Diffstat (limited to 'tests/tcctest.c')
-rw-r--r--tests/tcctest.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 0128957..f62983d 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -45,6 +45,7 @@
void string_test();
void expr_test();
void macro_test();
+void recursive_macro_test();
void scope_test();
void forward_test();
void funcptr_test();
@@ -281,6 +282,35 @@ comment
TEST2();
}
+
+static void print_num(char *fn, int line, int num) {
+ printf("fn %s, line %d, num %d\n", fn, line, num);
+}
+
+void recursive_macro_test(void)
+{
+#if 0 /* doesnt work yet */
+#define ELF32_ST_TYPE(val) ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+#define STB_WEAK 2 /* Weak symbol */
+#define ELFW(type) ELF##32##_##type
+ printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));
+#endif
+
+#define WRAP(x) x
+
+#define print_num(x) print_num(__FILE__,__LINE__,x)
+ print_num(123);
+ WRAP(print_num(123));
+ WRAP(WRAP(print_num(123)));
+
+static struct recursive_macro { int rm_field; } G;
+#define rm_field (G.rm_field)
+ printf("rm_field = %d\n", rm_field);
+ printf("rm_field = %d\n", WRAP(rm_field));
+ WRAP((printf("rm_field = %d %d\n", rm_field, WRAP(rm_field))));
+}
+
int op(a,b)
{
return a / b;
@@ -501,6 +531,7 @@ int main(int argc, char **argv)
string_test();
expr_test();
macro_test();
+ recursive_macro_test();
scope_test();
forward_test();
funcptr_test();