diff options
author | Devang Patel <dpatel@apple.com> | 2007-04-05 17:14:21 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-04-05 17:14:21 +0000 |
commit | f1bc4ad1e508b4cfb2a412e4ac298304ec54e6f8 (patch) | |
tree | 554f6bc55735f8b10e4fee597de79314d17f3610 /test/C++Frontend | |
parent | 13eb4c65874cba9c69b6ed1938c28649de2f3687 (diff) | |
download | external_llvm-f1bc4ad1e508b4cfb2a412e4ac298304ec54e6f8.zip external_llvm-f1bc4ad1e508b4cfb2a412e4ac298304ec54e6f8.tar.gz external_llvm-f1bc4ad1e508b4cfb2a412e4ac298304ec54e6f8.tar.bz2 |
New tests for Packed structs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/C++Frontend')
5 files changed, 123 insertions, 0 deletions
diff --git a/test/C++Frontend/2007-04-05-PackedBitFields-1.cpp b/test/C++Frontend/2007-04-05-PackedBitFields-1.cpp new file mode 100644 index 0000000..4797baf --- /dev/null +++ b/test/C++Frontend/2007-04-05-PackedBitFields-1.cpp @@ -0,0 +1,23 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +#ifdef PACKED +#define P __attribute__((packed)) +#else +#define P +#endif + +struct P M_Packed { + unsigned int l_Packed; + unsigned short k_Packed : 6, + i_Packed : 15, + j_Packed : 11; + +}; + +struct M_Packed sM_Packed; + +int testM_Packed (void) { + struct M_Packed x; + return (x.i_Packed != 0); +} + diff --git a/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap-2.cpp b/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap-2.cpp new file mode 100644 index 0000000..3ba5d7b --- /dev/null +++ b/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap-2.cpp @@ -0,0 +1,24 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +#ifdef PACKED +#define P __attribute__((packed)) +#else +#define P +#endif + +struct P M_Packed { + unsigned long sorted : 1; + unsigned long from_array : 1; + unsigned long mixed_encoding : 1; + unsigned long encoding : 8; + unsigned long count : 21; + +}; + +struct M_Packed sM_Packed; + +int testM_Packed (void) { + struct M_Packed x; + return (x.count != 0); +} + diff --git a/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap.cpp b/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap.cpp new file mode 100644 index 0000000..ad272c9 --- /dev/null +++ b/test/C++Frontend/2007-04-05-PackedBitFieldsOverlap.cpp @@ -0,0 +1,24 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +#ifdef PACKED +#define P __attribute__((packed)) +#else +#define P +#endif + +struct P M_Packed { + unsigned int l_Packed; + unsigned short k_Packed : 6, + i_Packed : 15; + char c; + +}; + +struct M_Packed sM_Packed; + +int testM_Packed (void) { + struct M_Packed x; + return (x.i_Packed != 0); +} + diff --git a/test/C++Frontend/2007-04-05-PackedBitFieldsSmall.cpp b/test/C++Frontend/2007-04-05-PackedBitFieldsSmall.cpp new file mode 100644 index 0000000..e7517dd --- /dev/null +++ b/test/C++Frontend/2007-04-05-PackedBitFieldsSmall.cpp @@ -0,0 +1,27 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +#ifdef PACKED +// This is an example where size of Packed struct is smaller then +// the size of bit field type. +#define P __attribute__((packed)) +#else +#define P +#endif + +struct P M_Packed { + unsigned long long X:50; + unsigned Y:2; +}; + +struct M_Packed sM_Packed; + +int testM_Packed (void) { + struct M_Packed x; + return (0 != x.Y); +} + +int testM_Packed2 (void) { + struct M_Packed x; + return (0 != x.X); +} diff --git a/test/C++Frontend/2007-04-05-StructPackedFieldUnpacked.cpp b/test/C++Frontend/2007-04-05-StructPackedFieldUnpacked.cpp new file mode 100644 index 0000000..52e2471 --- /dev/null +++ b/test/C++Frontend/2007-04-05-StructPackedFieldUnpacked.cpp @@ -0,0 +1,25 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +#ifdef PACKED +#define P __attribute__((packed)) +#else +#define P +#endif + +struct UnPacked { + int X; + int Y; +}; + +struct P M_Packed { + unsigned char A; + struct UnPacked B; +}; + +struct M_Packed sM_Packed; + +int testM_Packed (void) { + struct M_Packed x; + return (x.B.Y != 0); +} + |