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

Support complex __attribute__ involving __alignof__ #73

Open
jordr opened this issue Jan 5, 2023 · 6 comments
Open

Support complex __attribute__ involving __alignof__ #73

jordr opened this issue Jan 5, 2023 · 6 comments

Comments

@jordr
Copy link

jordr commented Jan 5, 2023

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?

@inducer
Copy link
Owner

inducer commented Jan 5, 2023

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

@jordr
Copy link
Author

jordr commented Jan 5, 2023

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

@retif
Copy link
Contributor

retif commented Jul 5, 2024

@jordr the issue here is pycparserext is not aware of __alignof__ keyword. It needs to be added to the lexer and parser in a similar way to how __typeof added here

Did you managed to solve this?

@jordr
Copy link
Author

jordr commented Jul 5, 2024

@jordr the issue here is pycparserext is not aware of __alignof__ keyword. It needs to be added to the lexer and parser in a similar way to how __typeof added here

Did you managed to solve this?

I believe I solved it the way you're describing in our fork a year ago, yes. My memory isn't that sharp though :)

@retif
Copy link
Contributor

retif commented Jul 5, 2024

@jordr it would be great if you could create a PR, or just add diff here as a comment(and i will do a PR).
I have stumbled on the same issue, and would be happy not to implement the fix myself to save some time :)

@jordr
Copy link
Author

jordr commented Jul 5, 2024

@jordr it would be great if you could create a PR, or just add diff here as a comment(and i will do a PR). I have stumbled on the same issue, and would be happy not to implement the fix myself to save some time :)

I don't have time for looking much into it right now, sorry. Maybe this commit will be useful to you: statinf-software/pycparser@deacf7d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants