Looking at https://www.lysator.liu.se/c/ANSI-C-grammar-y.html#direct-abstract-declarator, it seems like int f((int));
can be interpreted either as
- 'function f (int)' using the
'(' abstract_declarator ')'
rule or - 'function f(function(int))' using the
'(' parameter_type_list ')'
rule.
However, when I compile the file with bison
, it doesn't mention any shift-reduce conflicts besides the dangling if/else. cdecl
just says 'syntax error'. GCC and Clang seems to parse it as 2:
$ gcc -x c - -o /dev/stdout -S "$@"
int f((int));
<stdin>:1:7: error: expected declaration specifiers or '...' before '(' token
$ clang -x c - -o /dev/stdout -S "$@"
int f((int));
<stdin>:1:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
What's the proper way to parse this? Is this sufficiently arcane that I should just assume no one is using this part of the language?