]> git.draconx.ca Git - cdecl99.git/blob - tests/cdecl99-c-invalid.sh
e20af039296d0b0b30f35d58eb87929b0d4c6cc6
[cdecl99.git] / tests / cdecl99-c-invalid.sh
1 #!/bin/sh
2 #
3 # Copyright © 2012 Nick Bowler
4 #
5 # Check that cdecl99 rejects a variety of invalid declarations.
6 #
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
10
11 cdecl99=./cdecl99$EXEEXT
12 scriptname=$0
13
14 test_decl() {
15         if $cdecl99 -e "explain $*" >/dev/null 2>&1; then
16                 printf '%s: %s not rejected\n' "$scriptname" "$*" 1>&2
17                 return 1
18         fi
19
20         return 0
21 }
22
23 set -e
24 test_decl 'inline int x'
25 test_decl 'restrict int x'
26 test_decl 'static auto int x'
27 test_decl 'auto x'
28 test_decl 'int _Complex x'
29 test_decl 'typedef int'
30 test_decl 'void f(...)'
31 # XXX: While these silly void-parameter declarations are "obviously" invalid, I
32 # can't actually find a statement in the specification which forbids them.
33 test_decl 'void f(void, void)'
34 test_decl 'void f(register void)'
35 test_decl 'void f(const void)'
36 test_decl 'void f(const)'
37 test_decl 'void f(typedef int x)'
38 test_decl 'void f(static int x)'
39 test_decl 'int f(void)[1]'
40 test_decl 'int a[0]'
41 test_decl 'void a[1]'
42 test_decl 'int a[1](void)'