mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 21:56:04 +00:00

The packed attribute can still be useful in this case if the struct is then placed inside another packed struct - the non-pod element type's packed attribute declares that it's OK to misalign this element inside the packed structure. (otherwise the non-pod element is not packed/its alignment is preserved, as per D117616/2771233) Fixes PR62353 Differential Revision: https://reviews.llvm.org/D149182
33 lines
879 B
C++
33 lines
879 B
C++
// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -Wpacked \
|
|
// RUN: -fdump-record-layouts -fsyntax-only -verify -x c++ < %s | \
|
|
// RUN: FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -Wpacked \
|
|
// RUN: -fdump-record-layouts -fsyntax-only -verify -x c++ < %s | \
|
|
// RUN: FileCheck %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
struct A {
|
|
double d;
|
|
};
|
|
|
|
struct B {
|
|
char x[8];
|
|
};
|
|
|
|
struct [[gnu::packed]] C : B, A {
|
|
char x alignas(4)[8];
|
|
};
|
|
|
|
int b = sizeof(C);
|
|
|
|
// CHECK: 0 | struct C
|
|
// CHECK-NEXT: 0 | struct B (base)
|
|
// CHECK-NEXT: 0 | char[8] x
|
|
// CHECK-NEXT: 8 | struct A (base)
|
|
// CHECK-NEXT: 8 | double d
|
|
// CHECK-NEXT: 16 | char[8] x
|
|
// CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=4,
|
|
// CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=4]
|