Skip to content

Commit 61f307d

Browse files
emilioyouknowone
authored andcommitted
codegen: Don't generate conflicting packed() and align() representation hints.
Fixes #2240
1 parent 4093e87 commit 61f307d

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

src/codegen/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,9 @@ impl CodeGenerator for CompInfo {
20252025
attributes.push(attributes::repr("C"));
20262026
}
20272027

2028-
if ctx.options().rust_features().repr_align {
2028+
if ctx.options().rust_features().repr_align && !packed {
2029+
// We can't specify both packed(N) and align(N), but the align()
2030+
// should be redundant in this case.
20292031
if let Some(explicit) = explicit_align {
20302032
// Ensure that the struct has the correct alignment even in
20312033
// presence of alignas.

tests/expectations/struct_with_anon_struct_array_float.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/expectations/tests/packed-align-conflict.rs

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/headers/packed-align-conflict.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct FndrOpaqueInfo {
2+
char opaque[16];
3+
} __attribute__((aligned(2), packed));

0 commit comments

Comments
 (0)