]> git.draconx.ca Git - cdecl99.git/blob - tests/cdecl99-c-invalid.sh
Test more bogus declarations.
[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 'int x$'
25 test_decl 'long long long x'
26 test_decl 'inline int x'
27 test_decl 'restrict int x'
28 test_decl 'static auto int x'
29 test_decl 'auto x'
30 test_decl 'void x'
31 test_decl 'int _Complex x'
32 test_decl 'typedef int'
33 test_decl 'int x, (void)'
34 test_decl 'int [5], (void)'
35 test_decl 'void f(...)'
36 # XXX: While these silly void-parameter declarations are "obviously" invalid, I
37 # can't actually find a statement in the specification which forbids them.
38 test_decl 'void f(void, void)'
39 test_decl 'void f(void, ...)'
40 test_decl 'void f(register void)'
41 test_decl 'void f(const void)'
42 test_decl 'void f(void const)'
43 test_decl 'void f(const)'
44 test_decl 'void f(typedef int x)'
45 test_decl 'void f(static int x)'
46 test_decl 'int f(void)[1]'
47 test_decl 'inline int (void)'
48 test_decl 'int f((x))'
49 test_decl 'int f, g((x))'
50 test_decl 'int f(void), g(...)'
51 test_decl 'int f(inline int g())'
52 test_decl 'int f(void)(void)'
53 test_decl 'int ((int))'
54 test_decl 'int a[0]'
55 test_decl 'void a[1]'
56 test_decl 'int a[1](void)'
57 test_decl 'int a[1nan]'
58 test_decl 'int a[99999999999999999999999999999999999999999999999999999]'