summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2012-01-05 12:34:51 +0100
committerThomas Preud'homme <robotux@celest.fr>2012-01-05 12:34:51 +0100
commitd178eb7650ef7356ca4e6d9d64ac242dcff64811 (patch)
tree9f2084d9f6ace2c57691d8efd9ea2cc9bff8d197 /tests
parentcfef8921f4b5dfa31fd2336484d86e24e3beb2f3 (diff)
Imported Upstream version 0.9.26~git20120104.83d57c0
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile2
-rw-r--r--tests/tcctest.c21
2 files changed, 16 insertions, 7 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 36dd5fc..8cd906d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -20,7 +20,7 @@ endif
# run local version of tcc with local libraries and includes
TCC = ../tcc -B..
-RUN_TCC = $(NATIVE_DEFINES) -run ../tcc.c -B..
+RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B..
DISAS=objdump -d
all test : $(TESTS)
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 8d558e3..f0d82cf 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -103,6 +103,10 @@ int isid(int c);
#define HIGHLOW "hello"
#define LOW LOW ", world"
+static int onetwothree = 123;
+#define onetwothree4 onetwothree
+#define onetwothree xglue(onetwothree,4)
+
#define min(a, b) ((a) < (b) ? (a) : (b))
#ifdef C99_MACROS
@@ -155,6 +159,8 @@ void macro_test(void)
printf("s4=%s\n", str(a1));
printf("B3=%d\n", B3);
+ printf("onetwothree=%d\n", onetwothree);
+
#ifdef A
printf("A defined\n");
#endif
@@ -290,13 +296,12 @@ static void print_num(char *fn, int line, int 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
@@ -610,9 +615,9 @@ void scope_test()
printf("g5=%d\n", g);
}
-void array_test(int a[4])
+void array_test()
{
- int i, j;
+ int i, j, a[4];
printf("array:\n");
printf("sizeof(a) = %d\n", sizeof(a));
@@ -1296,6 +1301,8 @@ struct complexinit2 {
int b[];
};
+struct complexinit2 cix20;
+
struct complexinit2 cix21 = {
.a = 3000,
.b = { 3001, 3002, 3003 }
@@ -1405,7 +1412,7 @@ void init_test(void)
cix[0].b[1].a, cix[0].b[1].b,
cix[0].b[2].a, cix[0].b[2].b);
printf("cix2: %d %d\n", cix21.b[2], cix22.b[5]);
- printf("sizeof cix21 %d, sizeof cix22 %d\n", sizeof cix21, sizeof cix22);
+ printf("sizeof cix20 %d, cix21 %d, sizeof cix22 %d\n", sizeof cix20, sizeof cix21, sizeof cix22);
}
@@ -2076,6 +2083,8 @@ void *bounds_checking_is_enabled()
return (ca != cp + 1) ? cp : NULL;
}
+typedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];
+
void c99_vla_test(int size1, int size2)
{
#if defined __i386__ || defined __x86_64__
@@ -2440,8 +2449,8 @@ int some_lib_func(void);
int dummy_impl_of_slf(void) { return 444; }
int some_lib_func(void) __attribute__((weak, alias("dummy_impl_of_slf")));
-int weak_toolate() { return 0; }
int weak_toolate() __attribute__((weak));
+int weak_toolate() { return 0; }
void __attribute__((weak)) weak_test(void)
{