diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-10-26 22:31:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-10-26 22:31:14 +0000 |
commit | 1423a5cfd74eec46580bb5e655e5967b732b8c0d (patch) | |
tree | f88edb8b7e4948ab1d8fe6cc065ef040d290a75b /clang/test/CodeGenCXX/override-layout.cpp | |
parent | 9dd2e0872e045bc7fe3c664a81bb537569059623 (diff) | |
download | bcm5719-llvm-1423a5cfd74eec46580bb5e655e5967b732b8c0d.tar.gz bcm5719-llvm-1423a5cfd74eec46580bb5e655e5967b732b8c0d.zip |
When an externally-supplied record layout has a size that clearly
doesn't include padding up to the alignment of the record, take this
as a cue that the alignment of the record should (conservatively) be
set to 1. This is similar to other the other cues we use to determine
that the record has a lower alignment, e.g., that the
externally-supplied layout places fields at lower offsets than we
would. Fixes <rdar://problem/12582052>; test case in LLDB.
llvm-svn: 166824
Diffstat (limited to 'clang/test/CodeGenCXX/override-layout.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/override-layout.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/override-layout.cpp b/clang/test/CodeGenCXX/override-layout.cpp index d432885c584..aba4c9179a6 100644 --- a/clang/test/CodeGenCXX/override-layout.cpp +++ b/clang/test/CodeGenCXX/override-layout.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fdump-record-layouts-simple %s 2> %t.layouts // RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before 2>&1 // RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1 -// RUN: diff %t.before %t.after +// RUN: diff -u %t.before %t.after // RUN: FileCheck %s < %t.after // If not explicitly disabled, set PACKED to the packed attribute. @@ -54,11 +54,24 @@ struct PACKED X4 { X4(); }; +// CHECK: Type: struct X5 +struct PACKED X5 { + union { + long a; + long b; + }; + short l; + short r; +}; + void use_structs() { X0 x0s[sizeof(X0)]; X1 x1s[sizeof(X1)]; X2 x2s[sizeof(X2)]; X3 x3s[sizeof(X3)]; X4 x4s[sizeof(X4)]; + X5 x5s[sizeof(X5)]; x4s[1].a = 1; + x5s[1].a = 17; } + |