pycparserext icon indicating copy to clipboard operation
pycparserext copied to clipboard

Support complex __attribute__ involving __alignof__

Open jordr opened this issue 2 years ago • 6 comments

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?

jordr avatar Jan 05 '23 16:01 jordr

Sorry, I won't be able to help in the near term. But I would be happy to consider PRs along these lines.

inducer avatar Jan 05 '23 17:01 inducer

Thanks for the quick response, @inducer. I'll try to find a workaround.

jordr avatar Jan 05 '23 17:01 jordr