From 2bd0daabbe1fc40e65e4a4631e68f5ca093ea1fb Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 6 Jan 2014 19:56:26 +0100 Subject: misc. fixes - tccgen: error out for cast to void, as in void foo(void) { return 1; } This avoids an assertion failure in x86_64-gen.c, also. also fix tests2/03_struct.c accordingly - Error: "memory full" - be more specific - Makefiles: remove circular dependencies, lookup tcctest.c from VPATH - tcc.h: cleanup lib, include, crt and libgcc search paths" avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR (as from 9382d6f1a0e2d0104a82ed805207d9e742c6b068) - tcc.h: remove ";{B}" from PE search path in ce5e12c2f950052d8109b6b7a56d900547705c08 James Lyon wrote: "... I'm not sure this is the right way to fix this problem." And the answer is: No, please. (copying libtcc1.a for tests instead) - win32/build_tcc.bat: do not move away a versioned file --- tests/tests2/03_struct.c | 2 +- tests/tests2/Makefile | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'tests/tests2') diff --git a/tests/tests2/03_struct.c b/tests/tests2/03_struct.c index df0d3e7..c5d48c5 100644 --- a/tests/tests2/03_struct.c +++ b/tests/tests2/03_struct.c @@ -6,7 +6,7 @@ struct fred int natasha; }; -void main() +int main() { struct fred bloggs; diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 369ed47..51dc38d 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -96,6 +96,3 @@ all test: $(TESTS) clean: rm -vf fred.txt *.output - -Makefile: $(top_srcdir)/tests/tests2/Makefile - cp $< $@ -- cgit v1.3.1 From f1f45a47ef1c58e52a9599026ef666affc991b44 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 25 Mar 2014 20:54:19 +0800 Subject: Add test for previous commit * Adapt tests2 Makefile to support testing tcc error reporting * Add test for previous commit --- tests/tests2/56_btype_excess-1.c | 1 + tests/tests2/56_btype_excess-1.expect | 1 + tests/tests2/57_btype_excess-2.c | 1 + tests/tests2/57_btype_excess-2.expect | 1 + tests/tests2/Makefile | 10 ++++++---- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/tests2/56_btype_excess-1.c create mode 100644 tests/tests2/56_btype_excess-1.expect create mode 100644 tests/tests2/57_btype_excess-2.c create mode 100644 tests/tests2/57_btype_excess-2.expect (limited to 'tests/tests2') diff --git a/tests/tests2/56_btype_excess-1.c b/tests/tests2/56_btype_excess-1.c new file mode 100644 index 0000000..06eabe7 --- /dev/null +++ b/tests/tests2/56_btype_excess-1.c @@ -0,0 +1 @@ +struct A {} int i; diff --git a/tests/tests2/56_btype_excess-1.expect b/tests/tests2/56_btype_excess-1.expect new file mode 100644 index 0000000..4e6d2d7 --- /dev/null +++ b/tests/tests2/56_btype_excess-1.expect @@ -0,0 +1 @@ +56_btype_excess-1.c:1: error: too many basic types diff --git a/tests/tests2/57_btype_excess-2.c b/tests/tests2/57_btype_excess-2.c new file mode 100644 index 0000000..ab95c3e --- /dev/null +++ b/tests/tests2/57_btype_excess-2.c @@ -0,0 +1 @@ +char int i; diff --git a/tests/tests2/57_btype_excess-2.expect b/tests/tests2/57_btype_excess-2.expect new file mode 100644 index 0000000..c12ef81 --- /dev/null +++ b/tests/tests2/57_btype_excess-2.expect @@ -0,0 +1 @@ +57_btype_excess-2.c:1: error: too many basic types diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 51dc38d..c1bf5e6 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -67,7 +67,9 @@ TESTS = \ 51_static.test \ 52_unnamed_enum.test \ 54_goto.test \ - 55_lshift_type.test + 55_lshift_type.test \ + 56_btype_excess-1.test \ + 57_btype_excess-2.test # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard @@ -84,9 +86,9 @@ endif %.test: %.c %.expect @echo Test: $*... @if [ "x`echo $* | grep args`" != "x" ]; \ - then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output; \ - else $(TCC) -run $< >$*.output; \ - fi + then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \ + else $(TCC) -run $< >$*.output 2>&1; \ + fi || true @if diff -bu $(<:.c=.expect) $*.output ; \ then rm -f $*.output; \ else exit 1; \ -- cgit v1.3.1 From 80811671d439e4953961e3bcbe7ce09a34c96d2a Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sun, 30 Mar 2014 12:55:32 +0800 Subject: Add tests for previous fixes Add tests for the fixes made in commits 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6, a465b7f58fdea15caa1bfb81ff5e985c94c4df4a, 0f522fb32a635dafce30f3ce3ff2cb15bcec809e, 82969f045c99b4d1ef833de35117c17b326b46c0 and 673befd2d7745a90c1c4fcb6d2f0e266c04f8c97. --- tests/tests2/58_function_redefinition.c | 9 +++++++++ tests/tests2/58_function_redefinition.expect | 1 + tests/tests2/59_function_array.c | 1 + tests/tests2/59_function_array.expect | 1 + tests/tests2/60_enum_redefinition.c | 4 ++++ tests/tests2/60_enum_redefinition.expect | 1 + tests/tests2/61_undefined_enum.c | 1 + tests/tests2/61_undefined_enum.expect | 1 + tests/tests2/62_enumerator_redefinition.c | 4 ++++ tests/tests2/62_enumerator_redefinition.expect | 1 + tests/tests2/Makefile | 7 ++++++- 11 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/tests2/58_function_redefinition.c create mode 100644 tests/tests2/58_function_redefinition.expect create mode 100644 tests/tests2/59_function_array.c create mode 100644 tests/tests2/59_function_array.expect create mode 100644 tests/tests2/60_enum_redefinition.c create mode 100644 tests/tests2/60_enum_redefinition.expect create mode 100644 tests/tests2/61_undefined_enum.c create mode 100644 tests/tests2/61_undefined_enum.expect create mode 100644 tests/tests2/62_enumerator_redefinition.c create mode 100644 tests/tests2/62_enumerator_redefinition.expect (limited to 'tests/tests2') diff --git a/tests/tests2/58_function_redefinition.c b/tests/tests2/58_function_redefinition.c new file mode 100644 index 0000000..33f16ee --- /dev/null +++ b/tests/tests2/58_function_redefinition.c @@ -0,0 +1,9 @@ +int f(void) +{ + return 0; +} + +int f(void) +{ + return 1; +} diff --git a/tests/tests2/58_function_redefinition.expect b/tests/tests2/58_function_redefinition.expect new file mode 100644 index 0000000..a95a3f0 --- /dev/null +++ b/tests/tests2/58_function_redefinition.expect @@ -0,0 +1 @@ +58_function_redefinition.c:7: error: redefinition of 'f' diff --git a/tests/tests2/59_function_array.c b/tests/tests2/59_function_array.c new file mode 100644 index 0000000..9fcc12d --- /dev/null +++ b/tests/tests2/59_function_array.c @@ -0,0 +1 @@ +int (*fct)[42](int x); diff --git a/tests/tests2/59_function_array.expect b/tests/tests2/59_function_array.expect new file mode 100644 index 0000000..bf62c6e --- /dev/null +++ b/tests/tests2/59_function_array.expect @@ -0,0 +1 @@ +59_function_array.c:1: error: declaration of an array of functions diff --git a/tests/tests2/60_enum_redefinition.c b/tests/tests2/60_enum_redefinition.c new file mode 100644 index 0000000..2601560 --- /dev/null +++ b/tests/tests2/60_enum_redefinition.c @@ -0,0 +1,4 @@ +enum color {RED, GREEN, BLUE}; +enum color {R, G, B}; + +enum color c; diff --git a/tests/tests2/60_enum_redefinition.expect b/tests/tests2/60_enum_redefinition.expect new file mode 100644 index 0000000..5cb41bc --- /dev/null +++ b/tests/tests2/60_enum_redefinition.expect @@ -0,0 +1 @@ +60_enum_redefinition.c:2: error: struct/union/enum already defined diff --git a/tests/tests2/61_undefined_enum.c b/tests/tests2/61_undefined_enum.c new file mode 100644 index 0000000..bc7c6ea --- /dev/null +++ b/tests/tests2/61_undefined_enum.c @@ -0,0 +1 @@ +enum rgb c = 42; diff --git a/tests/tests2/61_undefined_enum.expect b/tests/tests2/61_undefined_enum.expect new file mode 100644 index 0000000..7ccdeca --- /dev/null +++ b/tests/tests2/61_undefined_enum.expect @@ -0,0 +1 @@ +61_undefined_enum.c:1: error: unknown struct/union/enum diff --git a/tests/tests2/62_enumerator_redefinition.c b/tests/tests2/62_enumerator_redefinition.c new file mode 100644 index 0000000..3da85ae --- /dev/null +++ b/tests/tests2/62_enumerator_redefinition.c @@ -0,0 +1,4 @@ +enum color {RED, GREEN, BLUE}; +enum rgb {RED, G, B}; + +enum color c = RED; diff --git a/tests/tests2/62_enumerator_redefinition.expect b/tests/tests2/62_enumerator_redefinition.expect new file mode 100644 index 0000000..3d0e879 --- /dev/null +++ b/tests/tests2/62_enumerator_redefinition.expect @@ -0,0 +1 @@ +62_enumerator_redefinition.c:2: error: redefinition of enumerator 'RED' diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index c1bf5e6..fa564f9 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -69,7 +69,12 @@ TESTS = \ 54_goto.test \ 55_lshift_type.test \ 56_btype_excess-1.test \ - 57_btype_excess-2.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 # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -- cgit v1.3.1 From 3e56584223a67a6c2f41a43cf38e0960e9992238 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Mon, 31 Mar 2014 22:58:17 +0800 Subject: Allow local redefinition of enumerator --- tccgen.c | 2 +- tests/tests2/63_local_enumerator_redefinition.c | 14 ++++++++++++++ tests/tests2/63_local_enumerator_redefinition.expect | 0 tests/tests2/Makefile | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/tests2/63_local_enumerator_redefinition.c create mode 100644 tests/tests2/63_local_enumerator_redefinition.expect (limited to 'tests/tests2') diff --git a/tccgen.c b/tccgen.c index 3171720..84188ad 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2827,7 +2827,7 @@ static void struct_decl(CType *type, int u, int tdef) if (v < TOK_UIDENT) expect("identifier"); ss = sym_find(v); - if (ss) + if (ss && !local_stack) tcc_error("redefinition of enumerator '%s'", get_tok_str(v, NULL)); next(); diff --git a/tests/tests2/63_local_enumerator_redefinition.c b/tests/tests2/63_local_enumerator_redefinition.c new file mode 100644 index 0000000..dd4d8e0 --- /dev/null +++ b/tests/tests2/63_local_enumerator_redefinition.c @@ -0,0 +1,14 @@ +enum { + FOO, + BAR +}; + +int main(void) +{ + enum { + FOO = 2, + BAR + }; + + return BAR - FOO; +} diff --git a/tests/tests2/63_local_enumerator_redefinition.expect b/tests/tests2/63_local_enumerator_redefinition.expect new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index fa564f9..bd6f2c1 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -74,7 +74,8 @@ TESTS = \ 59_function_array.test \ 60_enum_redefinition.test \ 61_undefined_enum.test \ - 62_enumerator_redefinition.test + 62_enumerator_redefinition.test \ + 63_local_enumerator_redefinition.test # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -- cgit v1.3.1 From 3d18c9aa64cdf5161453c54ed0302d28019282fe Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sat, 5 Apr 2014 17:35:00 +0200 Subject: tests2: Build executables as well The individual tests in tests2 are checked only with -run. Build (and check) executables as well, to test also building executables. --- tests/tests2/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/tests2') diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index bd6f2c1..d523b77 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -94,13 +94,18 @@ endif @if [ "x`echo $* | grep args`" != "x" ]; \ then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \ else $(TCC) -run $< >$*.output 2>&1; \ + ($(TCC) -o $*.exe $< -lm && ./$*.exe) >$*.output2 2>&1; \ fi || true @if diff -bu $(<:.c=.expect) $*.output ; \ then rm -f $*.output; \ else exit 1; \ fi + @if test -f $*.output2; then if diff -bu $(<:.c=.expect) $*.output2 ; \ + then rm -f $*.output2; \ + else exit 1; \ + fi; fi all test: $(TESTS) clean: - rm -vf fred.txt *.output + rm -vf fred.txt *.output* *.exe -- cgit v1.3.1 From 76accfb8d5b16664207fa8ae43d02b015bc8e019 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 7 Apr 2014 11:13:19 +0200 Subject: win32: libtcc1.a needs to be built with tcc gcc/mingw produces msvc compatible pecoff objects, tcc only knows ELF. --- lib/Makefile | 7 +++++-- tests/tests2/Makefile | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/tests2') diff --git a/lib/Makefile b/lib/Makefile index cf3cd71..e9e12f1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -6,7 +6,7 @@ TOP = .. include $(TOP)/Makefile VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib -ifndef TARGET +ifndef TARGET # native library ifdef CONFIG_WIN64 TARGET = x86_64-win32 else @@ -27,6 +27,7 @@ ifndef TARGET else ifeq ($(ARCH),arm) TARGET = arm + XCC = $(CC) endif endif endif @@ -58,12 +59,14 @@ ifeq "$(TARGET)" "i386-win32" TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include XAR = $(DIR)/tiny_libmaker$(EXESUF) + PICFLAGS = else ifeq "$(TARGET)" "x86_64-win32" OBJ = $(addprefix $(DIR)/,$(WIN64_O)) TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include XAR = $(DIR)/tiny_libmaker$(EXESUF) + PICFLAGS = else ifeq "$(TARGET)" "i386" OBJ = $(addprefix $(DIR)/,$(I386_O)) @@ -104,7 +107,7 @@ $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR) $(DIR)/%.o : %.c $(XCC) -c $< -o $@ $(XFLAGS) $(DIR)/%.o : %.S - $(CC) -c $< -o $@ $(XFLAGS) + $(XCC) -c $< -o $@ $(XFLAGS) $(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c $(CC) -o $@ $< $(XFLAGS) $(LDFLAGS) diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index d523b77..e5790c7 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -1,10 +1,10 @@ TOP = ../.. include $(TOP)/Makefile -VPATH = $(top_srcdir)/tests/tests2 -TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include ifdef CONFIG_WIN32 TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) +else + TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include -lm endif ifeq ($(TARGETOS),Darwin) @@ -94,7 +94,7 @@ endif @if [ "x`echo $* | grep args`" != "x" ]; \ then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \ else $(TCC) -run $< >$*.output 2>&1; \ - ($(TCC) -o $*.exe $< -lm && ./$*.exe) >$*.output2 2>&1; \ + ($(TCC) -o $*.exe $< && ./$*.exe) >$*.output2 2>&1; \ fi || true @if diff -bu $(<:.c=.expect) $*.output ; \ then rm -f $*.output; \ -- cgit v1.3.1 From f90bad092510c751afbd9286b9946691a416d2a1 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 7 Apr 2014 11:20:45 +0200 Subject: tests2: cleanup - remove -norunsrc switch Meaning and usage (-run -norun...???) look sort of screwed. Also general usefulness is unclear, so it was actually to support exactly one (not even very interesting) test This partially reverts e31579b0769e1f9c0947d12e83316d1149307b1a --- libtcc.c | 9 +-------- tcc.c | 1 - tests/tests2/31_args.c | 2 +- tests/tests2/31_args.expect | 11 +++++------ tests/tests2/Makefile | 35 +++++++++++++++++++---------------- 5 files changed, 26 insertions(+), 32 deletions(-) (limited to 'tests/tests2') diff --git a/libtcc.c b/libtcc.c index cc84cd7..5df1949 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1666,7 +1666,6 @@ enum { TCC_OPTION_pedantic, TCC_OPTION_pthread, TCC_OPTION_run, - TCC_OPTION_norunsrc, TCC_OPTION_v, TCC_OPTION_w, TCC_OPTION_pipe, @@ -1709,7 +1708,6 @@ static const TCCOption tcc_options[] = { { "pedantic", TCC_OPTION_pedantic, 0}, { "pthread", TCC_OPTION_pthread, 0}, { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, - { "norunsrc", TCC_OPTION_norunsrc, 0 }, { "rdynamic", TCC_OPTION_rdynamic, 0 }, { "r", TCC_OPTION_r, 0 }, { "s", TCC_OPTION_s, 0 }, @@ -1748,7 +1746,6 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) const TCCOption *popt; const char *optarg, *r; int run = 0; - int norunsrc = 0; int pthread = 0; int optind = 0; @@ -1761,8 +1758,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) r = argv[optind++]; if (r[0] != '-' || r[1] == '\0') { /* add a new file */ - if (!run || !norunsrc) - dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r)); + dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r)); if (run) { optind--; /* argv[0] will be this file */ @@ -1888,9 +1884,6 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) tcc_set_options(s, optarg); run = 1; break; - case TCC_OPTION_norunsrc: - norunsrc = 1; - break; case TCC_OPTION_v: do ++s->verbose; while (*optarg++ == 'v'); break; diff --git a/tcc.c b/tcc.c index 9b5ca2e..74a5f1b 100644 --- a/tcc.c +++ b/tcc.c @@ -69,7 +69,6 @@ static void help(void) " -Bdir use 'dir' as tcc internal library and include path\n" " -MD generate target dependencies for make\n" " -MF depfile put generated dependencies here\n" - " -norunsrc Do not compile the file which is the first argument after -run.\n" ); } diff --git a/tests/tests2/31_args.c b/tests/tests2/31_args.c index 275f8cf..dcafed5 100644 --- a/tests/tests2/31_args.c +++ b/tests/tests2/31_args.c @@ -5,7 +5,7 @@ int main(int argc, char **argv) int Count; printf("hello world %d\n", argc); - for (Count = 0; Count < argc; Count++) + for (Count = 1; Count < argc; Count++) printf("arg %d: %s\n", Count, argv[Count]); return 0; diff --git a/tests/tests2/31_args.expect b/tests/tests2/31_args.expect index c392b67..8c60bfc 100644 --- a/tests/tests2/31_args.expect +++ b/tests/tests2/31_args.expect @@ -1,7 +1,6 @@ hello world 6 -arg 0: 31_args.c -arg 1: - -arg 2: arg1 -arg 3: arg2 -arg 4: arg3 -arg 5: arg4 +arg 1: arg1 +arg 2: arg2 +arg 3: arg3 +arg 4: arg4 +arg 5: arg5 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index e5790c7..4d5546d 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -46,9 +46,11 @@ TESTS = \ 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 \ @@ -60,6 +62,7 @@ TESTS = \ 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 \ @@ -81,31 +84,31 @@ TESTS = \ # 34_array_assignment.test -- array assignment is not in C standard # 46_grep.test -- does not compile even with gcc +SKIP = 30_hanoi.test 34_array_assignment.test 46_grep.test + # some tests do not pass on all platforms, remove them for now ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out 40_stdio.test,$(TESTS)) + SKIP += 40_stdio.test endif ifdef CONFIG_WIN32 - TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS)) + SKIP += 24_math_library.test # don't have round() + SKIP += 28_strings.test # don't have r/index() / strings.h endif +# Some tests might need arguments +ARGS = +31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5 + +all test: $(filter-out $(SKIP),$(TESTS)) + %.test: %.c %.expect @echo Test: $*... - @if [ "x`echo $* | grep args`" != "x" ]; \ - then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \ - else $(TCC) -run $< >$*.output 2>&1; \ - ($(TCC) -o $*.exe $< && ./$*.exe) >$*.output2 2>&1; \ - fi || true - @if diff -bu $(<:.c=.expect) $*.output ; \ - then rm -f $*.output; \ - else exit 1; \ - fi - @if test -f $*.output2; then if diff -bu $(<:.c=.expect) $*.output2 ; \ - then rm -f $*.output2; \ - else exit 1; \ - fi; fi -all test: $(TESTS) + @$(TCC) -run $< $(ARGS) >$*.output 2>&1 || true + @diff -bu $*.expect $*.output && rm -f $*.output + + @($(TCC) $< -o $*.exe && ./$*.exe $(ARGS)) >$*.output2 2>&1 || true + @diff -bu $*.expect $*.output2 && rm -f $*.output2 $*.exe clean: rm -vf fred.txt *.output* *.exe -- cgit v1.3.1 From 3e9a7e9d69e3adb0e9ed65d11caf415e74458fe9 Mon Sep 17 00:00:00 2001 From: Vincent Lefevre Date: Mon, 7 Apr 2014 13:31:00 +0200 Subject: Corrected spelling mistakes in comments and strings --- arm-gen.c | 4 ++-- c67-gen.c | 4 ++-- i386-asm.c | 2 +- i386-tok.h | 2 +- include/stddef.h | 2 +- lib/bcheck.c | 2 +- tccasm.c | 2 +- tccgen.c | 4 ++-- tests/Makefile | 2 +- tests/tcctest.c | 2 +- tests/tests2/46_grep.c | 10 +++++----- 11 files changed, 18 insertions(+), 18 deletions(-) (limited to 'tests/tests2') diff --git a/arm-gen.c b/arm-gen.c index a9c05fe..680a490 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -943,7 +943,7 @@ struct plan { Returns the amount of stack space needed for parameter passing Note: this function allocated an array in plan->pplans with tcc_malloc. It - is the responsability of the caller to free this array once used (ie not + is the responsibility of the caller to free this array once used (ie not before copy_params). */ static int assign_regs(int nb_args, int float_abi, struct plan *plan, int *todo) { @@ -1860,7 +1860,7 @@ void gen_opf(int op) case TOK_UGE: case TOK_ULE: case TOK_UGT: - tcc_error("unsigned comparision on floats?"); + tcc_error("unsigned comparison on floats?"); break; case TOK_LT: op=TOK_Nset; diff --git a/c67-gen.c b/c67-gen.c index 6d9068a..a26dfaa 100644 --- a/c67-gen.c +++ b/c67-gen.c @@ -245,8 +245,8 @@ void gsym(int t) } // these are regs that tcc doesn't really know about, -// but asign them unique values so the mapping routines -// can distinquish them +// but assign them unique values so the mapping routines +// can distinguish them #define C67_A0 105 #define C67_SP 106 diff --git a/i386-asm.c b/i386-asm.c index 8473d06..a524658 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -1382,7 +1382,7 @@ ST_FUNC void subst_asm_operand(CString *add_str, } } -/* generate prolog and epilog code for asm statment */ +/* generate prolog and epilog code for asm statement */ ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, int nb_outputs, int is_output, uint8_t *clobber_regs, diff --git a/i386-tok.h b/i386-tok.h index d1e4bf3..6ba865d 100644 --- a/i386-tok.h +++ b/i386-tok.h @@ -191,7 +191,7 @@ DEF_FP(mul) DEF_ASM(fcom) - DEF_ASM(fcom_1) /* non existant op, just to have a regular table */ + DEF_ASM(fcom_1) /* non existent op, just to have a regular table */ DEF_FP1(com) DEF_FP(comp) diff --git a/include/stddef.h b/include/stddef.h index eaf0669..9e43de9 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -31,7 +31,7 @@ void *alloca(size_t size); by __need_wint_t, as otherwise stddef.h isn't allowed to define this type). Note that this must be outside the normal _STDDEF_H guard, so that it works even when we've included the file - already (without requring wint_t). Some other libs define _WINT_T + already (without requiring wint_t). Some other libs define _WINT_T if they've already provided that type, so we can use that as guard. TCC defines __WINT_TYPE__ for us. */ #if defined (__need_wint_t) diff --git a/lib/bcheck.c b/lib/bcheck.c index 968cdf4..76413ad 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -635,7 +635,7 @@ int __bound_delete_region(void *p) } /* return the size of the region starting at p, or EMPTY_SIZE if non - existant region. */ + existent region. */ static unsigned long get_region_size(void *p) { unsigned long addr = (unsigned long)p; diff --git a/tccasm.c b/tccasm.c index 9c77960..1c6a65d 100644 --- a/tccasm.c +++ b/tccasm.c @@ -232,7 +232,7 @@ static inline void asm_expr_sum(TCCState *s1, ExprValue *pe) } else { goto cannot_relocate; } - pe->sym = NULL; /* same symbols can be substracted to NULL */ + pe->sym = NULL; /* same symbols can be subtracted to NULL */ } else { cannot_relocate: tcc_error("invalid operation with label"); diff --git a/tccgen.c b/tccgen.c index e6e0fe1..ec92797 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1579,7 +1579,7 @@ static inline int is_integer_btype(int bt) bt == VT_INT || bt == VT_LLONG); } -/* check types for comparison or substraction of pointers */ +/* check types for comparison or subtraction of pointers */ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op) { CType *type1, *type2, tmp_type1, tmp_type2; @@ -5574,7 +5574,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, if (sym->type.t & VT_EXTERN) { /* if the variable is extern, it was not allocated */ sym->type.t &= ~VT_EXTERN; - /* set array size if it was ommited in extern + /* set array size if it was omitted in extern declaration */ if ((sym->type.t & VT_ARRAY) && sym->type.ref->c < 0 && diff --git a/tests/Makefile b/tests/Makefile index 55bf29c..ee0eafe 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -158,7 +158,7 @@ btest: boundtest.c @for i in $(BOUNDS_OK); do \ echo ; echo --- boundtest $$i ---; \ if $(TCC) -b -run $< $$i ; then \ - echo succeded as expected; \ + echo succeeded as expected; \ else\ echo Failed positive test $$i ; exit 1 ; \ fi ;\ diff --git a/tests/tcctest.c b/tests/tcctest.c index c48c1bc..cc8ffd8 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -2254,7 +2254,7 @@ void c99_vla_test(int size1, int size2) printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED"); tab1_ptr = tab1; tab2_ptr = tab2; - printf("Test C99 VLA 2 (ptrs substract): "); + printf("Test C99 VLA 2 (ptrs subtract): "); printf("%s\n", (tab2 - tab1 == (tab2_ptr - tab1_ptr) / (sizeof(int) * 2)) ? "PASSED" : "FAILED"); printf("Test C99 VLA 3 (ptr add): "); printf("%s\n", &tab1[5][1] == (tab1_ptr + (5 * 2 + 1) * sizeof(int)) ? "PASSED" : "FAILED"); diff --git a/tests/tests2/46_grep.c b/tests/tests2/46_grep.c index 5f52220..27589a4 100644 --- a/tests/tests2/46_grep.c +++ b/tests/tests2/46_grep.c @@ -29,10 +29,10 @@ char *documentation[] = { "grep searches a file for a given pattern. Execute by", " grep [flags] regular_expression file_list\n", - "Flags are single characters preceeded by '-':", + "Flags are single characters preceded by '-':", " -c Only a count of matching lines is printed", " -f Print file name for matching lines switch, see below", - " -n Each line is preceeded by its line number", + " -n Each line is preceded by its line number", " -v Only print non-matching lines\n", "The file_list is a list of files (wildcards are acceptable on RSX modes).", "\nThe file name is normally printed if there is a file given.", @@ -54,10 +54,10 @@ char *patdoc[] = { "':n' \":n\" matches alphanumerics, \": \" matches spaces, tabs, and", "': ' other control characters, such as new-line.", "'*' An expression followed by an asterisk matches zero or more", - " occurrances of that expression: \"fo*\" matches \"f\", \"fo\"", + " occurrences of that expression: \"fo*\" matches \"f\", \"fo\"", " \"foo\", etc.", "'+' An expression followed by a plus sign matches one or more", - " occurrances of that expression: \"fo+\" matches \"fo\", etc.", + " occurrences of that expression: \"fo+\" matches \"fo\", etc.", "'-' An expression followed by a minus sign optionally matches", " the expression.", "'[]' A string enclosed in square brackets matches any character in", @@ -153,7 +153,7 @@ void compile(char *source) o == STAR || o == PLUS || o == MINUS) - badpat("Illegal occurrance op.", source, s); + badpat("Illegal occurrence op.", source, s); store(ENDPAT); store(ENDPAT); spp = pp; /* Save pattern end */ -- cgit v1.3.1 From 91d4db600bd95318c224100f13b79de9fdd5ca79 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Mon, 7 Apr 2014 23:30:57 +0800 Subject: Add new tests for macro nesting --- tests/tests2/64_macro_nesting.c | 10 ++++++++++ tests/tests2/64_macro_nesting.expect | 1 + tests/tests2/Makefile | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/tests2/64_macro_nesting.c create mode 100644 tests/tests2/64_macro_nesting.expect (limited to 'tests/tests2') diff --git a/tests/tests2/64_macro_nesting.c b/tests/tests2/64_macro_nesting.c new file mode 100644 index 0000000..44b582f --- /dev/null +++ b/tests/tests2/64_macro_nesting.c @@ -0,0 +1,10 @@ +#define CAT2(a,b) a##b +#define CAT(a,b) CAT2(a,b) +#define AB(x) CAT(x,y) + +int main(void) +{ + int xy = 42; + printf("%d\n", CAT(A,B)(x)); + return 0; +} diff --git a/tests/tests2/64_macro_nesting.expect b/tests/tests2/64_macro_nesting.expect new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/tests/tests2/64_macro_nesting.expect @@ -0,0 +1 @@ +42 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 4d5546d..36d84dc 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -78,7 +78,8 @@ TESTS = \ 60_enum_redefinition.test \ 61_undefined_enum.test \ 62_enumerator_redefinition.test \ - 63_local_enumerator_redefinition.test + 63_local_enumerator_redefinition.test \ + 64_macro_nesting.test # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -- cgit v1.3.1 From a715d7143d9d17da17e67fec6af1c01409a71a31 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 8 Apr 2014 22:19:48 +0800 Subject: Prevent ## to appear at start or end of macro --- tccpp.c | 14 +++++++++++--- tests/tests2/65_macro_concat_start.c | 2 ++ tests/tests2/65_macro_concat_start.expect | 1 + tests/tests2/66_macro_concat_end.c | 2 ++ tests/tests2/66_macro_concat_end.expect | 1 + tests/tests2/Makefile | 4 +++- 6 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 tests/tests2/65_macro_concat_start.c create mode 100644 tests/tests2/65_macro_concat_start.expect create mode 100644 tests/tests2/66_macro_concat_end.c create mode 100644 tests/tests2/66_macro_concat_end.expect (limited to 'tests/tests2') diff --git a/tccpp.c b/tccpp.c index 7144ee4..c8beec5 100644 --- a/tccpp.c +++ b/tccpp.c @@ -1213,9 +1213,9 @@ static void tok_print(int *str) ST_FUNC void parse_define(void) { Sym *s, *first, **ps; - int v, t, varg, is_vaargs, spc; + int v, t, varg, is_vaargs, spc, ptok, macro_list_start; TokenString str; - + v = tok; if (v < TOK_IDENT) tcc_error("invalid macro name '%s'", get_tok_str(tok, &tokc)); @@ -1254,8 +1254,13 @@ ST_FUNC void parse_define(void) tok_str_new(&str); spc = 2; /* EOF testing necessary for '-D' handling */ + ptok = 0; + macro_list_start = 1; while (tok != TOK_LINEFEED && tok != TOK_EOF) { - /* remove spaces around ## and after '#' */ + if (!macro_list_start && spc == 2 && tok == TOK_TWOSHARPS) + tcc_error("'##' invalid at start of macro"); + ptok = tok; + /* remove spaces around ## and after '#' */ if (TOK_TWOSHARPS == tok) { if (1 == spc) --str.len; @@ -1268,7 +1273,10 @@ ST_FUNC void parse_define(void) tok_str_add2(&str, tok, &tokc); skip: next_nomacro_spc(); + macro_list_start = 0; } + if (ptok == TOK_TWOSHARPS) + tcc_error("'##' invalid at end of macro"); if (spc == 1) --str.len; /* remove trailing space */ tok_str_add(&str, 0); diff --git a/tests/tests2/65_macro_concat_start.c b/tests/tests2/65_macro_concat_start.c new file mode 100644 index 0000000..d63d67a --- /dev/null +++ b/tests/tests2/65_macro_concat_start.c @@ -0,0 +1,2 @@ +#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 new file mode 100644 index 0000000..88ed6c5 --- /dev/null +++ b/tests/tests2/65_macro_concat_start.expect @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..55dcaef --- /dev/null +++ b/tests/tests2/66_macro_concat_end.c @@ -0,0 +1,2 @@ +#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 new file mode 100644 index 0000000..224e5c9 --- /dev/null +++ b/tests/tests2/66_macro_concat_end.expect @@ -0,0 +1 @@ +66_macro_concat_end.c:2: error: '##' invalid at end of macro diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 36d84dc..41adb2d 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -79,7 +79,9 @@ TESTS = \ 61_undefined_enum.test \ 62_enumerator_redefinition.test \ 63_local_enumerator_redefinition.test \ - 64_macro_nesting.test + 64_macro_nesting.test \ + 65_macro_concat_start.test \ + 66_macro_concat_end.test # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -- cgit v1.3.1 From 6e56bb387db8af055ff6de71a23b270de55c3dc8 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 12 Apr 2014 12:00:13 +0800 Subject: Fix preprocessor concat with empty arg --- tcc.h | 1 + tccpp.c | 42 ++++++++++++++++++++++++++++++++----- tests/tests2/67_macro_concat.c | 14 +++++++++++++ tests/tests2/67_macro_concat.expect | 2 ++ tests/tests2/Makefile | 3 ++- 5 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 tests/tests2/67_macro_concat.c create mode 100644 tests/tests2/67_macro_concat.expect (limited to 'tests/tests2') diff --git a/tcc.h b/tcc.h index 9955839..dda2fc1 100644 --- a/tcc.h +++ b/tcc.h @@ -836,6 +836,7 @@ struct TCCState { /* <-- */ #define TOK_TWOSHARPS 0xc0 /* ## preprocessing token */ +#define TOK_PLCHLDR 0xc1 /* placeholder token as defined in C99 */ #define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */ #define TOK_ADDC1 0xc3 /* add with carry generation */ #define TOK_ADDC2 0xc4 /* add with carry use */ diff --git a/tccpp.c b/tccpp.c index c8beec5..dfdee50 100644 --- a/tccpp.c +++ b/tccpp.c @@ -2565,7 +2565,8 @@ ST_FUNC void next_nomacro(void) } while (is_space(tok)); } -/* substitute args in macro_str and return allocated string */ +/* substitute arguments in replacement lists in macro_str by the values in + args (field d) and return allocated string */ static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args) { int last_tok, t, spc; @@ -2622,7 +2623,7 @@ static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args) if (gnu_ext && s->type.t && last_tok == TOK_TWOSHARPS && str.len >= 2 && str.str[str.len - 2] == ',') { - if (*st == 0) { + if (*st == TOK_PLCHLDR) { /* suppress ',' '##' */ str.len -= 2; } else { @@ -2793,6 +2794,8 @@ static int macro_subst_tok(TokenString *tok_str, tok_str_add2(&str, tok, &tokc); next_nomacro_spc(); } + if (!str.len) + tok_str_add(&str, TOK_PLCHLDR); str.len -= spc; tok_str_add(&str, 0); sa1 = sym_push2(&args, sa->v & ~SYM_FIELD, sa->type.t, 0); @@ -2885,9 +2888,11 @@ static inline int *macro_twosharps(const int *macro_str) TOK_GET(&t, &ptr, &cval); /* We concatenate the two tokens */ cstr_new(&cstr); - cstr_cat(&cstr, get_tok_str(tok, &tokc)); + if (tok != TOK_PLCHLDR) + cstr_cat(&cstr, get_tok_str(tok, &tokc)); n = cstr.size; - cstr_cat(&cstr, get_tok_str(t, &cval)); + if (t != TOK_PLCHLDR || tok == TOK_PLCHLDR) + cstr_cat(&cstr, get_tok_str(t, &cval)); cstr_ccat(&cstr, '\0'); tcc_open_bf(tcc_state, ":paste:", cstr.size); @@ -2904,8 +2909,35 @@ static inline int *macro_twosharps(const int *macro_str) cstr_free(&cstr); } } - if (tok != TOK_NOSUBST) + if (tok != TOK_NOSUBST) { + const int *oldptr; + CValue cval; + + /* Check if a space need to be added after ## concatenation in + order to avoid misinterpreting the newly formed token + followed by the next token as being a single token (see + macro_concat test) */ + cstr_new(&cstr); + cstr_cat(&cstr, get_tok_str(tok, &tokc)); + oldptr = ptr; + TOK_GET(&t, &ptr, &cval); + ptr = oldptr; + cstr_cat(&cstr, get_tok_str(t, &cval)); + cstr_ccat(&cstr, '\0'); + t = tok; + cval = tokc; + tcc_open_bf(tcc_state, ":paste:", cstr.size); + memcpy(file->buffer, cstr.data, cstr.size); + next_nomacro1(); + if (!*file->buf_ptr) { + tok_str_add2(¯o_str1, t, &cval); + tok = ' '; + } + tcc_close(); + cstr_free(&cstr); + start_of_nosubsts = -1; + } tok_str_add2(¯o_str1, tok, &tokc); } tok_str_add(¯o_str1, 0); diff --git a/tests/tests2/67_macro_concat.c b/tests/tests2/67_macro_concat.c new file mode 100644 index 0000000..c580d3a --- /dev/null +++ b/tests/tests2/67_macro_concat.c @@ -0,0 +1,14 @@ +#include + +#define P(A,B) A ## B ; bob +#define Q(A,B) A ## B+ + +int main(void) +{ + int bob, jim = 21; + bob = P(jim,) *= 2; + printf("jim: %d, bob: %d\n", jim, bob); + jim = 60 Q(+,)3; + printf("jim: %d\n", jim); + return 0; +} diff --git a/tests/tests2/67_macro_concat.expect b/tests/tests2/67_macro_concat.expect new file mode 100644 index 0000000..8386c2d --- /dev/null +++ b/tests/tests2/67_macro_concat.expect @@ -0,0 +1,2 @@ +jim: 21, bob: 42 +jim: 63 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 41adb2d..a7c8a2f 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -81,7 +81,8 @@ TESTS = \ 63_local_enumerator_redefinition.test \ 64_macro_nesting.test \ 65_macro_concat_start.test \ - 66_macro_concat_end.test + 66_macro_concat_end.test \ + 67_macro_concat.test # 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -- cgit v1.3.1 From 0a51386960bcf116cce03fe61e21effd875cd792 Mon Sep 17 00:00:00 2001 From: minux Date: Sat, 12 Apr 2014 13:37:37 -0400 Subject: tests2: fix 30_hanoi test and enable it. --- tests/tests2/30_hanoi.c | 2 +- tests/tests2/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/tests2') diff --git a/tests/tests2/30_hanoi.c b/tests/tests2/30_hanoi.c index b1a1181..7c0893b 100644 --- a/tests/tests2/30_hanoi.c +++ b/tests/tests2/30_hanoi.c @@ -68,7 +68,7 @@ void PrintAll() /* Returns the value moved (not used.) */ int Move(int *source, int *dest) { - int i,j; + int i = 0, j = 0; while (i Date: Sat, 12 Apr 2014 14:04:10 -0400 Subject: tests2: fix and enable 46_grep test. --- tests/tests2/46_grep.c | 13 ++++++++----- tests/tests2/46_grep.expect | 3 +++ tests/tests2/Makefile | 5 ++--- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 tests/tests2/46_grep.expect (limited to 'tests/tests2') diff --git a/tests/tests2/46_grep.c b/tests/tests2/46_grep.c index 27589a4..3123bc3 100644 --- a/tests/tests2/46_grep.c +++ b/tests/tests2/46_grep.c @@ -15,6 +15,7 @@ * privileges were granted by DECUS. */ #include +#include /* * grep @@ -25,7 +26,6 @@ * See below for more information. */ -#if 0 char *documentation[] = { "grep searches a file for a given pattern. Execute by", " grep [flags] regular_expression file_list\n", @@ -70,7 +70,6 @@ char *patdoc[] = { " [a-z] matches alphabetics, while [z-a] never matches.", "The concatenation of regular expressions is a regular expression.", 0}; -#endif #define LMAX 512 #define PMAX 256 @@ -97,6 +96,10 @@ char *pp, lbuf[LMAX], pbuf[PMAX]; char *cclass(); char *pmatch(); +void store(int); +void error(char *); +void badpat(char *, char *, char *); +int match(void); /*** Display a file name *******************************/ @@ -300,7 +303,7 @@ void badpat(char *message, char *source, char *stop) /* char *stop; // Pattern end */ { fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source); - fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", + fprintf(stderr, "-GREP-E-Stopped at byte %ld, '%c'\n", stop-source, stop[-1]); error("?GREP-E-Bad pattern\n"); } @@ -338,7 +341,7 @@ void grep(FILE *fp, char *fn) } /*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/ -void match() +int match() { char *l; /* Line pointer */ @@ -368,7 +371,7 @@ char *pmatch(char *line, char *pattern) p = pattern; while ((op = *p++) != ENDPAT) { if (debug > 1) - printf("byte[%d] = 0%o, '%c', op = 0%o\n", + printf("byte[%ld] = 0%o, '%c', op = 0%o\n", l-line, *l, *l, op); switch(op) { diff --git a/tests/tests2/46_grep.expect b/tests/tests2/46_grep.expect new file mode 100644 index 0000000..e8a6791 --- /dev/null +++ b/tests/tests2/46_grep.expect @@ -0,0 +1,3 @@ +File 46_grep.c: +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 6e0fa34..c47fe0a 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -84,11 +84,9 @@ TESTS = \ 66_macro_concat_end.test \ 67_macro_concat.test -# 30_hanoi.test -- seg fault in the code, gcc as well # 34_array_assignment.test -- array assignment is not in C standard -# 46_grep.test -- does not compile even with gcc -SKIP = 34_array_assignment.test 46_grep.test +SKIP = 34_array_assignment.test # some tests do not pass on all platforms, remove them for now ifeq ($(TARGETOS),Darwin) @@ -102,6 +100,7 @@ endif # Some tests might need arguments ARGS = 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5 +46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c all test: $(filter-out $(SKIP),$(TESTS)) -- cgit v1.3.1