Commit graph

1 commit

Author SHA1 Message Date
drpriver
7dd0506aaf
Fix #21150 - ImportC: alignment value expected, not _Alignof (#21180)
The gnu attribute aligned() allows specifying the alignment of an entire
struct, mostly as a syntatic convenience. This attribute allows
compile-time integer expressions, but the parser was trying to evaluate them
ahead of time by checking for an integer literal. Instead we need to
preserve the expression and defer it to a later semantic stage.
Accomplish this by emulating the behavior by specifying the alignment of
the first member of the struct.

I didn't change how __declspec(align(#)) parses as from the
documentation it seems to only allow integer literals. Some light
testing with cl.exe gives syntax errors when trying to use _Alignof() in
that position.
2025-04-09 10:59:26 +08:00