]> git.draconx.ca Git - cdecl99.git/commitdiff
Test invalid English declarations as well.
authorNick Bowler <nbowler@draconx.ca>
Thu, 3 May 2012 23:54:30 +0000 (19:54 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 3 May 2012 23:54:30 +0000 (19:54 -0400)
tests/cdecl99-c-invalid.sh

index 7aaba30310dc7954e556e8304d95cb8f925cb34e..5ffb3b39a61a0b298314be7e32f23d57d0c0acc6 100755 (executable)
@@ -12,7 +12,10 @@ cdecl99=./cdecl99$EXEEXT
 scriptname=$0
 
 test_decl() {
-       if $cdecl99 -e "explain $*" >/dev/null 2>&1; then
+       cmd=$1
+       shift
+
+       if $cdecl99 -e "$cmd $*" >/dev/null 2>&1; then
                printf '%s: %s not rejected\n' "$scriptname" "$*" 1>&2
                return 1
        fi
@@ -21,38 +24,66 @@ test_decl() {
 }
 
 set -e
-test_decl 'int x$'
-test_decl 'long long long x'
-test_decl 'inline int x'
-test_decl 'restrict int x'
-test_decl 'static auto int x'
-test_decl 'auto x'
-test_decl 'void x'
-test_decl 'int _Complex x'
-test_decl 'typedef int'
-test_decl 'int x, (void)'
-test_decl 'int [5], (void)'
-test_decl 'void f(...)'
+test_decl explain 'int x$'
+test_decl declare 'x$ as int'
+test_decl explain 'long long long x'
+test_decl declare 'x as long long long'
+test_decl explain 'inline int x'
+test_decl declare 'x as inline int'
+test_decl explain 'restrict int x'
+test_decl declare 'x as restrict int'
+test_decl explain 'static auto int x'
+test_decl declare 'x as static auto int'
+test_decl explain 'auto x'
+test_decl declare 'x as auto'
+test_decl explain 'void x'
+test_decl declare 'x as void'
+test_decl explain 'int _Complex x'
+test_decl declare 'x as int _Complex'
+test_decl explain 'typedef int'
+test_decl type    'typedef int'
+test_decl explain 'void f(...)'
+test_decl declare 'f as function (...) returning void'
 # 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(void, ...)'
-test_decl 'void f(register void)'
-test_decl 'void f(const void)'
-test_decl 'void f(void const)'
-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 'inline int (void)'
-test_decl 'int f((x))'
-test_decl 'int f, g((x))'
-test_decl 'int f(void), g(...)'
-test_decl 'int f(inline int g())'
-test_decl 'int f(void)(void)'
-test_decl 'int ((int))'
-test_decl 'int a[0]'
-test_decl 'void a[1]'
-test_decl 'int a[1](void)'
-test_decl 'int a[1nan]'
-test_decl 'int a[99999999999999999999999999999999999999999999999999999]'
+test_decl explain 'void f(void, void)'
+test_decl declare 'f as function (void, void) returning void'
+test_decl explain 'void f(void, ...)'
+test_decl declare 'f as function (void, ...) returning void'
+test_decl explain 'void f(register void)'
+test_decl declare 'f as function (register void) returning void'
+test_decl explain 'void f(const void)'
+test_decl declare 'f as function (const void) returning void'
+test_decl explain 'void f(void const)'
+test_decl declare 'f as function (void const) returning void'
+test_decl explain 'void f(const)'
+test_decl declare 'f as function (const) returning void'
+test_decl explain 'void f(typedef int x)'
+test_decl declare 'f as function (x as typedef int) returning void'
+test_decl explain 'void f(static int x)'
+test_decl declare 'f as function (x as static int) returning void'
+test_decl explain 'int f(void)[1]'
+test_decl declare 'f as function (void) returning array 1 of int'
+test_decl explain 'inline int (void)'
+test_decl type    'inline function (void) returning int'
+test_decl explain 'int f(inline int g())'
+test_decl declare 'f as function (g as inline function returning int) returning int'
+test_decl explain 'int f(void)(void)'
+test_decl declare 'f as function (void) returning function (void) returning int'
+test_decl explain 'int a[0]'
+test_decl declare 'a as array 0 of int'
+test_decl explain 'void a[1]'
+test_decl declare 'a as array 1 of void'
+test_decl explain 'int a[1](void)'
+test_decl declare 'a as array 1 of function (void) returning int'
+test_decl explain 'int a[1nan]'
+test_decl declare 'a as array 1nan of int'
+test_decl explain 'int a[99999999999999999999999999999999999999999999999999999]'
+test_decl declare 'a as array 99999999999999999999999999999999999999999999999999999 of int'
+
+test_decl explain 'int f((x))'
+test_decl explain 'int f(void), g(...)'
+test_decl explain 'int f, g((x))'
+test_decl explain 'int x, (void)'
+test_decl explain 'int [5], (void)'
+test_decl explain 'int ((int))'