Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't parse function declaration with unnamed static array #539

Closed
gperciva opened this issue May 1, 2024 · 1 comment
Closed

Can't parse function declaration with unnamed static array #539

gperciva opened this issue May 1, 2024 · 1 comment

Comments

@gperciva
Copy link
Contributor

gperciva commented May 1, 2024

Thanks for this library! I'm having great fun using it to nitpick some code.

Attempting to parse a function declaration with an unnamed static array:

from pycparser.c_parser import CParser
CParser().parse('void f(int [static 10]);')

fails with:

  File "/usr/local/lib/python3.9/site-packages/pycparser/plyparser.py", line 67, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: :1:13: before: static

If we name the argument -- i.e. (int x[static 10]) -- then it works fine (since the example would be exactly the same as #21, the issue which prompted support for static arrays in the first place). Omitting the argument name is valid in C99.

I'm using pycparser 2.22. Thanks again for this library!

@eliben
Copy link
Owner

eliben commented May 4, 2024

PRs to add support are welcome :)

gperciva added a commit to Tarsnap/pycparser that referenced this issue Jun 19, 2024
This is similar to:
    allow "static" in array parameters (GH issue eliben#21)
    aac7b27
which was revised shortly after in:
    Fuller support for qualifiers in array dimensions.
    8aad318

The grammar is as defined in C99 6.7.6 Type names, or
A.2.2 Declarations (6.7.6).
@eliben eliben closed this as completed in ab00af8 Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants