T
Tor Rustad
Did a fun project some years ago.. a cdecl, but never really tested it.
Here are some test cases I just tried:
cdecl> char **argv;
cdecl> argv is pointer to pointer to char
Looks ok
cdecl> int (*daytab)[13];
cdecl> daytab is pointer to array [13] of int
Looks ok
cdecl> int *daytab[13];
cdecl> daytab is array [13] of pointer to int
Looks ok
cdecl> void *comp();
cdecl> comp is function returning pointer to void
Looks ok
cdecl> char (*(*x())[])();
cdecl> x is function returning pointer to array of pointer to function
returning char
Looks ok
cdecl> char (*(*x[3])())[5];
cdecl> x is array [3] of pointer to function returning pointer to array
[5] of char
Looks ok
cdecl> char* const *(*next)();
cdecl> next is pointer to function returning pointer to (read-only)
pointer to char
Parse error: ";" at line 255. Hint: Not a valid type.
Looks ok, except for the parse error.
cdecl> char **(c[10])(int **p);
cdecl> c is array [10] of function returning pointer to pointer to char
Looks ok
cdecl> void (*signal(int sig, void (*func)(int)))(int);
cdecl> signal is function returning pointer to void
cdecl> void (*signal(int, void (*)(int)))(int);
cdecl> signal is function returning pointer to void
Not ok
Did I miss something here, or do people agree with the above?
(I don't have another cdecl to cross-check with)
Does someone have ideas for more test-cases?
Here are some test cases I just tried:
cdecl> char **argv;
cdecl> argv is pointer to pointer to char
Looks ok
cdecl> int (*daytab)[13];
cdecl> daytab is pointer to array [13] of int
Looks ok
cdecl> int *daytab[13];
cdecl> daytab is array [13] of pointer to int
Looks ok
cdecl> void *comp();
cdecl> comp is function returning pointer to void
Looks ok
cdecl> char (*(*x())[])();
cdecl> x is function returning pointer to array of pointer to function
returning char
Looks ok
cdecl> char (*(*x[3])())[5];
cdecl> x is array [3] of pointer to function returning pointer to array
[5] of char
Looks ok
cdecl> char* const *(*next)();
cdecl> next is pointer to function returning pointer to (read-only)
pointer to char
Parse error: ";" at line 255. Hint: Not a valid type.
Looks ok, except for the parse error.
cdecl> char **(c[10])(int **p);
cdecl> c is array [10] of function returning pointer to pointer to char
Looks ok
cdecl> void (*signal(int sig, void (*func)(int)))(int);
cdecl> signal is function returning pointer to void
cdecl> void (*signal(int, void (*)(int)))(int);
cdecl> signal is function returning pointer to void
Not ok
Did I miss something here, or do people agree with the above?
(I don't have another cdecl to cross-check with)
Does someone have ideas for more test-cases?