aboutsummaryrefslogtreecommitdiff
path: root/tests/tests2
diff options
context:
space:
mode:
authorgrischka <grischka>2015-05-09 14:29:39 +0200
committergrischka <grischka>2015-05-09 14:29:39 +0200
commit30df3189b177c65d65094bed3a066a2722fe2dc0 (patch)
tree5cc01304899af2f09b051cdb5cf980ceb8f6b9c1 /tests/tests2
parent70a6c4601e471054edbe2fd984e37e2ca320db14 (diff)
downloadtinycc-30df3189b177c65d65094bed3a066a2722fe2dc0.tar.gz
tinycc-30df3189b177c65d65094bed3a066a2722fe2dc0.tar.bz2
tccpp: fix issues, add tests
* fix some macro expansion issues * add some pp tests in tests/pp * improved tcc -E output for better diff'ability * remove -dD feature (quirky code, exotic feature, didn't work well) Based partially on ideas / researches from PipCet Some issues remain with VA_ARGS macros (if used in a rather tricky way). Also, to keep it simple, the pp doesn't automtically add any extra spaces to separate tokens which otherwise would form wrong tokens if re-read from tcc -E output (such as '+' '=') GCC does that, other compilers don't. * cleanups - #line 01 "file" / # 01 "file" processing - #pragma comment(lib,"foo") - tcc -E: forward some pragmas to output (pack, comment(lib)) - fix macro parameter list parsing mess from a3fc54345949535524d01319e1ca6378b7c2c201 a715d7143d9d17da17e67fec6af1c01409a71a31 (some coffee might help, next time ;) - introduce TOK_PPSTR - to have character constants as written in the file (similar to TOK_PPNUM) - allow '\' appear in macros - new functions begin/end_macro to: - fix switching macro levels during expansion - allow unget_tok to unget more than one tok - slight speedup by using bitflags in isidnum_table Also: - x86_64.c : fix decl after statements - i386-gen,c : fix a vstack leak with VLA on windows - configure/Makefile : build on windows (MSYS) was broken - tcc_warning: fflush stderr to keep output order (win32)
Diffstat (limited to 'tests/tests2')
-rw-r--r--tests/tests2/65_macro_concat_start.c2
-rw-r--r--tests/tests2/65_macro_concat_start.expect1
-rw-r--r--tests/tests2/66_macro_concat_end.c2
-rw-r--r--tests/tests2/66_macro_concat_end.expect1
-rw-r--r--tests/tests2/68_macro_param_list_err_1.c9
-rw-r--r--tests/tests2/68_macro_param_list_err_1.expect1
-rw-r--r--tests/tests2/69_macro_param_list_err_2.c9
-rw-r--r--tests/tests2/69_macro_param_list_err_2.expect1
-rw-r--r--tests/tests2/72_long_long_constant.c2
-rw-r--r--tests/tests2/72_long_long_constant.expect1
-rw-r--r--tests/tests2/Makefile107
11 files changed, 23 insertions, 113 deletions
diff --git a/tests/tests2/65_macro_concat_start.c b/tests/tests2/65_macro_concat_start.c
deleted file mode 100644
index d63d67a..0000000
--- a/tests/tests2/65_macro_concat_start.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define paste(A,B) ##A B
-paste(x,y)
diff --git a/tests/tests2/65_macro_concat_start.expect b/tests/tests2/65_macro_concat_start.expect
deleted file mode 100644
index 88ed6c5..0000000
--- a/tests/tests2/65_macro_concat_start.expect
+++ /dev/null
@@ -1 +0,0 @@
-65_macro_concat_start.c:1: error: '##' invalid at start of macro
diff --git a/tests/tests2/66_macro_concat_end.c b/tests/tests2/66_macro_concat_end.c
deleted file mode 100644
index 55dcaef..0000000
--- a/tests/tests2/66_macro_concat_end.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define paste(A,B) A B##
-paste(x,y)
diff --git a/tests/tests2/66_macro_concat_end.expect b/tests/tests2/66_macro_concat_end.expect
deleted file mode 100644
index 224e5c9..0000000
--- a/tests/tests2/66_macro_concat_end.expect
+++ /dev/null
@@ -1 +0,0 @@
-66_macro_concat_end.c:2: error: '##' invalid at end of macro
diff --git a/tests/tests2/68_macro_param_list_err_1.c b/tests/tests2/68_macro_param_list_err_1.c
deleted file mode 100644
index fd08dc7..0000000
--- a/tests/tests2/68_macro_param_list_err_1.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdio.h>
-#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c)
-
-int main(void)
-{
- int c = 0xa;
- printf("hex: %c\n", hexCh(c));
- return 0;
-}
diff --git a/tests/tests2/68_macro_param_list_err_1.expect b/tests/tests2/68_macro_param_list_err_1.expect
deleted file mode 100644
index 3246640..0000000
--- a/tests/tests2/68_macro_param_list_err_1.expect
+++ /dev/null
@@ -1 +0,0 @@
-68_macro_param_list_err_1.c:2: error: '(' may not appear in parameter list
diff --git a/tests/tests2/69_macro_param_list_err_2.c b/tests/tests2/69_macro_param_list_err_2.c
deleted file mode 100644
index 06f0b41..0000000
--- a/tests/tests2/69_macro_param_list_err_2.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdio.h>
-#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c)
-
-int main(void)
-{
- int c = 0xa;
- printf("hex: %c\n", hexCh(c));
- return 0;
-}
diff --git a/tests/tests2/69_macro_param_list_err_2.expect b/tests/tests2/69_macro_param_list_err_2.expect
deleted file mode 100644
index 6d6b9d1..0000000
--- a/tests/tests2/69_macro_param_list_err_2.expect
+++ /dev/null
@@ -1 +0,0 @@
-69_macro_param_list_err_2.c:2: error: '/' may not appear in parameter list
diff --git a/tests/tests2/72_long_long_constant.c b/tests/tests2/72_long_long_constant.c
index a698fd6..6608213 100644
--- a/tests/tests2/72_long_long_constant.c
+++ b/tests/tests2/72_long_long_constant.c
@@ -13,5 +13,7 @@ int main()
printf("Error: 2147483647 < 0\n");
return 2;
}
+ else
+ printf("long long constant test ok.\n");
return 0;
}
diff --git a/tests/tests2/72_long_long_constant.expect b/tests/tests2/72_long_long_constant.expect
new file mode 100644
index 0000000..dda9e66
--- /dev/null
+++ b/tests/tests2/72_long_long_constant.expect
@@ -0,0 +1 @@
+long long constant test ok.
diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile
index a441674..254fa5c 100644
--- a/tests/tests2/Makefile
+++ b/tests/tests2/Makefile
@@ -19,89 +19,9 @@ endif
TCC = $(TOP)/tcc $(TCCFLAGS)
-TESTS = \
- 00_assignment.test \
- 01_comment.test \
- 02_printf.test \
- 03_struct.test \
- 04_for.test \
- 05_array.test \
- 06_case.test \
- 07_function.test \
- 08_while.test \
- 09_do_while.test \
- 10_pointer.test \
- 11_precedence.test \
- 12_hashdefine.test \
- 13_integer_literals.test \
- 14_if.test \
- 15_recursion.test \
- 16_nesting.test \
- 17_enum.test \
- 18_include.test \
- 19_pointer_arithmetic.test \
- 20_pointer_comparison.test \
- 21_char_array.test \
- 22_floating_point.test \
- 23_type_coercion.test \
- 24_math_library.test \
- 25_quicksort.test \
- 26_character_constants.test \
- 27_sizeof.test \
- 28_strings.test \
- 29_array_address.test \
- 30_hanoi.test \
- 31_args.test \
- 32_led.test \
- 33_ternary_op.test \
- 34_array_assignment.test \
- 35_sizeof.test \
- 36_array_initialisers.test \
- 37_sprintf.test \
- 38_multiple_array_index.test \
- 39_typedef.test \
- 40_stdio.test \
- 41_hashif.test \
- 42_function_pointer.test \
- 43_void_param.test \
- 44_scoped_declarations.test \
- 45_empty_for.test \
- 46_grep.test \
- 47_switch_return.test \
- 48_nested_break.test \
- 49_bracket_evaluation.test \
- 50_logical_second_arg.test \
- 51_static.test \
- 52_unnamed_enum.test \
- 54_goto.test \
- 55_lshift_type.test \
- 56_btype_excess-1.test \
- 57_btype_excess-2.test \
- 58_function_redefinition.test \
- 59_function_array.test \
- 60_enum_redefinition.test \
- 61_undefined_enum.test \
- 62_enumerator_redefinition.test \
- 63_local_enumerator_redefinition.test \
- 64_macro_nesting.test \
- 65_macro_concat_start.test \
- 66_macro_concat_end.test \
- 67_macro_concat.test \
- 68_macro_param_list_err_1.test \
- 69_macro_param_list_err_2.test \
- 70_floating_point_literals.test \
- 71_macro_empty_arg.test \
- 72_long_long_constant.test \
- 73_arm64.test \
- 74_nocode_wanted.test \
- 75_array_in_struct_init.test \
- 76_dollars_in_identifiers.test \
- 77_push_pop_macro.test \
- 78_vla_label.test \
- 79_vla_continue.test
+TESTS = $(patsubst %.c,%.test,$(wildcard *.c))
# 34_array_assignment.test -- array assignment is not in C standard
-
SKIP = 34_array_assignment.test
# some tests do not pass on all platforms, remove them for now
@@ -128,16 +48,29 @@ ARGS =
FLAGS =
76_dollars_in_identifiers.test : FLAGS = -fdollars-in-identifiers
+# Filter some always-warning
+FILTER =
+ifeq (-$(findstring arm,$(ARCH))-,-arm-)
+FILTER = 2>&1 | grep -v 'warning: soft float ABI currently not supported'
+endif
+
all test: $(filter-out $(SKIP),$(TESTS))
-%.test: %.c
+%.test: %.c %.expect
@echo Test: $*...
-
- @$(TCC) -run $(FLAGS) $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true
+# test -run
+ @$(TCC) $(FLAGS) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true
@diff -Nbu $*.expect $*.output && rm -f $*.output
+# test exe (disabled for speed)
+# @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) $(FiLTER) >$*.output2 2>&1 ; \
+# diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe
+
+# automatically generate .expect files with gcc:
+%.expect :
+ (gcc $*.c -o a.exe && ./a.exe $(ARGS)) >$*.expect 2>&1; rm -f a.exe
- @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true
- @diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe
+# tell make not to delete
+.PRECIOUS: %.expect
clean:
- rm -vf fred.txt *.output* *.exe
+ rm -vf fred.txt *.output a.exe