pycparserext
pycparserext copied to clipboard
Support complex __attribute__ involving __alignof__
Pycparser breaks on this example:
diff --git a/test/test_pycparserext.py b/test/test_pycparserext.py
index 183769f..357061c 100644
--- a/test/test_pycparserext.py
+++ b/test/test_pycparserext.py
@@ -245,6 +245,7 @@ def test_array_attributes():
src = """
int x[10] __attribute__((unused));
int y[20] __attribute((aligned(10)));
+ long long z __attribute__((aligned(__alignof__(long long))));
"""
from pycparserext.ext_c_parser import GnuCParser
The error vanishes if I simplify the __attribute__
or replace __alignof__
by (for example) sizeof
.
__alignof__
is supported by GNU : https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Alignment.html
I was not able to engineer a good solution so far. Can we have a generic __attribute__((whatever(foo(long long))))
solution or do we have to manually add __alignof__
keywords and the like?
Sorry, I won't be able to help in the near term. But I would be happy to consider PRs along these lines.
Thanks for the quick response, @inducer. I'll try to find a workaround.