Skip to content

Commit e8168ce

Browse files
committed
codegen: Don't generate conflicting packed() and align() representation hints.
Fixes #2240
1 parent 105b942 commit e8168ce

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

src/codegen/mod.rs

+3-1
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

-1
This file was deleted.

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

+38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/headers/packed-align-conflict.h

+3
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)