]> git.draconx.ca Git - cdecl99.git/commit
libcdecl: Fix parsing of int (x(*)()) etc.
authorNick Bowler <nbowler@draconx.ca>
Fri, 12 Jan 2024 03:50:20 +0000 (22:50 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 12 Jan 2024 05:38:35 +0000 (00:38 -0500)
commit23bee8f66fbd14c308d3c509a59024768bc2feef
treec32e8d41cc287044c2df3df6b8ea754f1364587e
parenta41aa156f28753613f38924fc856d3dc992cfc56
libcdecl: Fix parsing of int (x(*)()) etc.

An incomplete earlier fix for misparsing "int (x*)" didn't correct the
issue for more complex abstract declarators like (*)() or (*)[1][2][3].
The function simplification step is erroneously applied even though
there is no valid parse of "int (x(*)[])" in which x is an identifier
declarator.

In the prior release 1.2, int (x(*)) happens to be parsed correctly but
int (x(*)[]) produces a bogus result.  Since the release, the behaviour
was changed to spit out a syntax error for both, so there is a bit of
regression here.

The randomdecl test rarely generates these so the problem can show up
intermittently.  Add some more conditions so we don't try to simplify
these declarations, and new dedicated test cases to check these.
src/parse-decl.c
tests/decl-good.at