mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00

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.
9 lines
347 B
OpenEdge ABL
9 lines
347 B
OpenEdge ABL
/* TEST_OUTPUT:
|
|
---
|
|
fail_compilation/alignedext2.i(8): Error: alignment must be an integer positive power of 2, not 0x7b
|
|
fail_compilation/alignedext2.i(9): Error: alignment must be an integer positive power of 2, not 0x10000
|
|
---
|
|
*/
|
|
|
|
typedef struct __attribute__((aligned(123))) U { int a; } S;
|
|
struct __attribute__((aligned(65536))) V { int a; };
|