From: Nick Bowler Date: Fri, 23 Mar 2012 19:38:49 +0000 (-0400) Subject: Add a simple test to check if cdecl99 rejects bogus input. X-Git-Tag: v1~49 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/7d32ec18c46f9b8313dc8b815b994ff2c85d26c7 Add a simple test to check if cdecl99 rejects bogus input. --- diff --git a/Makefile.am b/Makefile.am index 296a222..4972bd2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,7 +75,8 @@ TEST_EXTENSIONS = .sh SH_LOG_COMPILER = $(SHELL) TESTS = tests/libcdecl-static-symbols.sh tests/randomdecl-sanity.sh \ - tests/crossparse-c-random.sh + tests/crossparse-c-random.sh tests/cdecl99-c-invalid.sh + EXTRA_DIST += $(TESTS) src/parse.lo: src/scan.h diff --git a/tests/cdecl99-c-invalid.sh b/tests/cdecl99-c-invalid.sh new file mode 100755 index 0000000..e20af03 --- /dev/null +++ b/tests/cdecl99-c-invalid.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright © 2012 Nick Bowler +# +# Check that cdecl99 rejects a variety of invalid declarations. +# +# License WTFPL2: Do What The Fuck You Want To Public License, version 2. +# This is free software: you are free to do what the fuck you want to. +# There is NO WARRANTY, to the extent permitted by law. + +cdecl99=./cdecl99$EXEEXT +scriptname=$0 + +test_decl() { + if $cdecl99 -e "explain $*" >/dev/null 2>&1; then + printf '%s: %s not rejected\n' "$scriptname" "$*" 1>&2 + return 1 + fi + + return 0 +} + +set -e +test_decl 'inline int x' +test_decl 'restrict int x' +test_decl 'static auto int x' +test_decl 'auto x' +test_decl 'int _Complex x' +test_decl 'typedef int' +test_decl 'void f(...)' +# XXX: While these silly void-parameter declarations are "obviously" invalid, I +# can't actually find a statement in the specification which forbids them. +test_decl 'void f(void, void)' +test_decl 'void f(register void)' +test_decl 'void f(const void)' +test_decl 'void f(const)' +test_decl 'void f(typedef int x)' +test_decl 'void f(static int x)' +test_decl 'int f(void)[1]' +test_decl 'int a[0]' +test_decl 'void a[1]' +test_decl 'int a[1](void)'