diff options
Diffstat (limited to 'cparser/tests')
-rw-r--r-- | cparser/tests/generated/Makefile | 50 | ||||
-rw-r--r-- | cparser/tests/handwritten/conditional-0.c | 4 | ||||
-rw-r--r-- | cparser/tests/handwritten/conditional-1.c | 4 | ||||
-rw-r--r-- | cparser/tests/handwritten/dubious-enum.c | 7 | ||||
-rw-r--r-- | cparser/tests/handwritten/missing-assignment.c | 4 | ||||
-rw-r--r-- | cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c | 10 | ||||
-rw-r--r-- | cparser/tests/handwritten/missing-loop-body.c | 5 | ||||
-rw-r--r-- | cparser/tests/handwritten/missing-operator.c | 5 | ||||
-rw-r--r-- | cparser/tests/handwritten/missing-semicolon.c | 5 | ||||
-rw-r--r-- | cparser/tests/handwritten/too-many-closing-parens.c | 4 | ||||
-rw-r--r-- | cparser/tests/handwritten/unclosed-paren.c | 5 | ||||
-rw-r--r-- | cparser/tests/handwritten/variable-type-confusion.c | 6 |
12 files changed, 109 insertions, 0 deletions
diff --git a/cparser/tests/generated/Makefile b/cparser/tests/generated/Makefile new file mode 100644 index 00000000..fb6e7610 --- /dev/null +++ b/cparser/tests/generated/Makefile @@ -0,0 +1,50 @@ +####################################################################### +# # +# The Compcert verified compiler # +# # +# François Pottier, INRIA Paris-Rocquencourt # +# # +# Copyright Institut National de Recherche en Informatique et en # +# Automatique. All rights reserved. This file is distributed # +# under the terms of the INRIA Non-Commercial License Agreement. # +# # +####################################################################### + +.PHONY: all clean + +SOURCES := $(wildcard *.c) +TARGETS := \ + $(patsubst %.c,%.ccomp.err,$(SOURCES)) \ + $(patsubst %.c,%.gcc.err,$(SOURCES)) \ + $(patsubst %.c,%.clang.err,$(SOURCES)) + +CCOMP := ../../../ccomp +GCC := gcc +CLANG := clang + +all: $(TARGETS) + +clean: + @ rm -f *.err *~ + +%.ccomp.err: %.c $(CCOMP) + @ echo $(CCOMP) -c $< + @ if $(CCOMP) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(CCOMP) -c $< SUCCEEDED!" ; \ + fi + @ if grep "unknown syntax error" $@ ; then \ + echo "UNKNOWN SYNTAX ERROR!" ; \ + fi + +%.gcc.err: %.c + @ echo $(GCC) -c $< + @ if $(GCC) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(GCC) -c $< SUCCEEDED!" ; \ + fi + +%.clang.err: %.c + @ echo $(CLANG) -c $< + @ if $(CLANG) -c $< 2>$@ ; then \ + echo "UNEXPECTED SUCCESS: $(CLANG) -c $< SUCCEEDED!" ; \ + fi + diff --git a/cparser/tests/handwritten/conditional-0.c b/cparser/tests/handwritten/conditional-0.c new file mode 100644 index 00000000..4aeb4659 --- /dev/null +++ b/cparser/tests/handwritten/conditional-0.c @@ -0,0 +1,4 @@ +int main (int x, int y) +{ + return x == 0 ? x : y == 0 : y; +} diff --git a/cparser/tests/handwritten/conditional-1.c b/cparser/tests/handwritten/conditional-1.c new file mode 100644 index 00000000..c6a5210a --- /dev/null +++ b/cparser/tests/handwritten/conditional-1.c @@ -0,0 +1,4 @@ +int main (int x, int y) +{ + return x == 0 ? x : y == 0 ? y; +} diff --git a/cparser/tests/handwritten/dubious-enum.c b/cparser/tests/handwritten/dubious-enum.c new file mode 100644 index 00000000..12ee6683 --- /dev/null +++ b/cparser/tests/handwritten/dubious-enum.c @@ -0,0 +1,7 @@ +int f (void) +{ + int x = sizeof(enum e; + /* Maybe a closing parenthesis is missing, + maybe also "enum e" could be continued with an opening brace. + Our message ignores the latter possibility. */ +} diff --git a/cparser/tests/handwritten/missing-assignment.c b/cparser/tests/handwritten/missing-assignment.c new file mode 100644 index 00000000..2fce2cbf --- /dev/null +++ b/cparser/tests/handwritten/missing-assignment.c @@ -0,0 +1,4 @@ +int main (void) +{ + int x = 10, y 8; +} diff --git a/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c b/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c new file mode 100644 index 00000000..dfb3691d --- /dev/null +++ b/cparser/tests/handwritten/missing-closing-brace-at-end-of-function.c @@ -0,0 +1,10 @@ +int main (void) +{ + int x = 0; + x++; + /* missing closing brace, here */ + /* unfortunately, the error is detected only after the declaration of f */ + +void f (void) +{ +} diff --git a/cparser/tests/handwritten/missing-loop-body.c b/cparser/tests/handwritten/missing-loop-body.c new file mode 100644 index 00000000..44781564 --- /dev/null +++ b/cparser/tests/handwritten/missing-loop-body.c @@ -0,0 +1,5 @@ +int main (void) +{ + int x = 10; + while (x--) /* missing loop body */ +} diff --git a/cparser/tests/handwritten/missing-operator.c b/cparser/tests/handwritten/missing-operator.c new file mode 100644 index 00000000..d93e91f4 --- /dev/null +++ b/cparser/tests/handwritten/missing-operator.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7, z = 8; + int x = (3 * (2 x) - y * y); +} diff --git a/cparser/tests/handwritten/missing-semicolon.c b/cparser/tests/handwritten/missing-semicolon.c new file mode 100644 index 00000000..a655ca3b --- /dev/null +++ b/cparser/tests/handwritten/missing-semicolon.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7, z = 8 + int x = (3 * (2 + x) - y * y); +} diff --git a/cparser/tests/handwritten/too-many-closing-parens.c b/cparser/tests/handwritten/too-many-closing-parens.c new file mode 100644 index 00000000..68fe0b62 --- /dev/null +++ b/cparser/tests/handwritten/too-many-closing-parens.c @@ -0,0 +1,4 @@ +int main (void) +{ + int x = main()); +} diff --git a/cparser/tests/handwritten/unclosed-paren.c b/cparser/tests/handwritten/unclosed-paren.c new file mode 100644 index 00000000..b0ef6747 --- /dev/null +++ b/cparser/tests/handwritten/unclosed-paren.c @@ -0,0 +1,5 @@ +int main (void) +{ + int y = 7; + int x = (3 * (2 + x) - y * y; +} diff --git a/cparser/tests/handwritten/variable-type-confusion.c b/cparser/tests/handwritten/variable-type-confusion.c new file mode 100644 index 00000000..0957ca9d --- /dev/null +++ b/cparser/tests/handwritten/variable-type-confusion.c @@ -0,0 +1,6 @@ +typedef int t; +typedef int u; +int f (void) { + t = 3; +} + |