mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 12:50:00 +00:00
New tests for Packed structs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35686 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
13eb4c6587
commit
f1bc4ad1e5
23
test/C++Frontend/2007-04-05-PackedBitFields-1.cpp
Normal file
23
test/C++Frontend/2007-04-05-PackedBitFields-1.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
24
test/C++Frontend/2007-04-05-PackedBitFieldsOverlap-2.cpp
Normal file
24
test/C++Frontend/2007-04-05-PackedBitFieldsOverlap-2.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
24
test/C++Frontend/2007-04-05-PackedBitFieldsOverlap.cpp
Normal file
24
test/C++Frontend/2007-04-05-PackedBitFieldsOverlap.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
27
test/C++Frontend/2007-04-05-PackedBitFieldsSmall.cpp
Normal file
27
test/C++Frontend/2007-04-05-PackedBitFieldsSmall.cpp
Normal file
@ -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);
|
||||
}
|
25
test/C++Frontend/2007-04-05-StructPackedFieldUnpacked.cpp
Normal file
25
test/C++Frontend/2007-04-05-StructPackedFieldUnpacked.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user