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
--- /dev/null
+#!/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)'