diff options
author | Eric Christopher <echristo@apple.com> | 2011-08-19 23:08:33 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2011-08-19 23:08:33 +0000 |
commit | 17db038966474d8be47964c913cdc3019fe1aa8b (patch) | |
tree | e196e8053231bfbc7b2ee29452393e35d4dd25b4 /clang/test/CodeGenCXX | |
parent | 7d47a66379ba8800b34f601c4bdd0606f1623bf2 (diff) | |
download | bcm5719-llvm-17db038966474d8be47964c913cdc3019fe1aa8b.tar.gz bcm5719-llvm-17db038966474d8be47964c913cdc3019fe1aa8b.zip |
Migrate:
2007-01-06-PtrMethodInit.cpp
2007-04-05-PackedBitFields-1.cpp
2007-04-05-PackedBitFieldsOverlap-2.cpp
2007-04-05-PackedBitFieldsOverlap.cpp
2007-04-05-PackedBitFieldsSmall.cpp
2007-04-05-StructPackedFieldUnpacked.cpp
2007-04-10-PackedUnion.cpp
2007-04-14-FNoBuiltin.cpp
2007-05-03-VectorInit.cpp
2007-07-29-RestrictPtrArg.cpp
2007-07-29-RestrictRefArg.cpp
2007-09-10-RecursiveTypeResolution.cpp
from llvm/test/FrontendC++ and FileCheckize where appropriate.
llvm-svn: 138134
Diffstat (limited to 'clang/test/CodeGenCXX')
12 files changed, 361 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp b/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp new file mode 100644 index 00000000000..f3aa51e725b --- /dev/null +++ b/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp @@ -0,0 +1,75 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - +// PR1084 + +extern "C" +{ + typedef unsigned char PRUint8; + typedef unsigned int PRUint32; +} +typedef PRUint32 nsresult; +struct nsID +{ +}; +typedef nsID nsIID; +class nsISupports +{ +}; +extern "C++" +{ + template < class T > struct nsCOMTypeInfo + { + static const nsIID & GetIID () + { + } + }; +} + +class nsIDOMEvent:public nsISupports +{ +}; +class nsIDOMEventListener:public nsISupports +{ +public:static const nsIID & GetIID () + { + } + virtual nsresult + __attribute__ ((regparm (0), cdecl)) HandleEvent (nsIDOMEvent * event) = + 0; +}; +class nsIDOMMouseListener:public nsIDOMEventListener +{ +public:static const nsIID & GetIID () + { + static const nsIID iid = { + }; + } + virtual nsresult + __attribute__ ((regparm (0), + cdecl)) MouseDown (nsIDOMEvent * aMouseEvent) = 0; +}; +typedef +typeof (&nsIDOMEventListener::HandleEvent) + GenericHandler; + struct EventDispatchData + { + PRUint32 message; + GenericHandler method; + PRUint8 bits; + }; + struct EventTypeData + { + const EventDispatchData *events; + int numEvents; + const nsIID *iid; + }; + static const EventDispatchData sMouseEvents[] = { + { + (300 + 2), + reinterpret_cast < GenericHandler > (&nsIDOMMouseListener::MouseDown), + 0x01} + }; +static const EventTypeData sEventTypes[] = { + { + sMouseEvents, (sizeof (sMouseEvents) / sizeof (sMouseEvents[0])), + &nsCOMTypeInfo < nsIDOMMouseListener >::GetIID ()} +}; diff --git a/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp new file mode 100644 index 00000000000..6c39b55fd33 --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +#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/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp new file mode 100644 index 00000000000..d7b0eaeae1a --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +#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/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp new file mode 100644 index 00000000000..69117673925 --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + + +#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/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp new file mode 100644 index 00000000000..b31f95fa3b8 --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + + +#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/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp b/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp new file mode 100644 index 00000000000..c848e7cb7dd --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +#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); +} diff --git a/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp b/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp new file mode 100644 index 00000000000..863fc82692e --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -emit-llvm %s -o /dev/null +extern "C" { + +#pragma pack(push, 2) + typedef struct ABC* abc; + + struct ABCS { + float red; + float green; + float blue; + float alpha; + }; + + typedef void (*XYZ)(); +#pragma pack(pop) +} + + +union ABCU { + ABCS color; + XYZ bg; +}; + +struct AData { + ABCU data; +}; + +class L { + public: + L() {} + L(const L& other); + + private: + AData fdata; +}; + + +L::L(const L& other) +{ + fdata = other.fdata; +} diff --git a/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp b/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp new file mode 100644 index 00000000000..4475fda95c0 --- /dev/null +++ b/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -emit-llvm %s -fno-builtin -o - | FileCheck %s +// Check that -fno-builtin is honored. + +extern "C" int printf(const char*, ...); +void foo(const char *msg) { + // CHECK: call{{.*}}printf + printf("%s\n",msg); +} diff --git a/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp b/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp new file mode 100644 index 00000000000..5bc196f30fe --- /dev/null +++ b/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -emit-llvm %s -O0 -o - +// PR1378 + +typedef float v4sf __attribute__((vector_size(16))); + +typedef v4sf float4; + +static float4 splat4(float a) +{ + float4 tmp = {a,a,a,a}; + return tmp; +} + +float4 foo(float a) +{ + return splat4(a); +} diff --git a/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp b/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp new file mode 100644 index 00000000000..d7c96f562ac --- /dev/null +++ b/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +void foo(int * __restrict myptr1, int * myptr2) { + // CHECK: noalias + myptr1[0] = 0; + myptr2[0] = 0; +} diff --git a/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp b/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp new file mode 100644 index 00000000000..aa9f48bb0ab --- /dev/null +++ b/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +void foo(int & __restrict myptr1, int & myptr2) { + // CHECK: noalias + myptr1 = 0; + myptr2 = 0; +} diff --git a/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp b/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp new file mode 100644 index 00000000000..ec8a516c696 --- /dev/null +++ b/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp @@ -0,0 +1,87 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - +// PR1634 + +namespace Manta +{ + class CallbackHandle + { + protected:virtual ~ CallbackHandle (void) + { + } + }; +template < typename Data1 > class CallbackBase_1Data:public CallbackHandle + { + }; +} + +namespace __gnu_cxx +{ + template < typename _Iterator, typename _Container > + class __normal_iterator + { + _Iterator _M_current; + }; +} + +namespace std +{ + template < typename _Tp > struct allocator + { + typedef _Tp *pointer; + }; + template < typename _InputIterator, + typename _Tp > inline void find (_InputIterator __last, + const _Tp & __val) + { + }; +} + +namespace Manta +{ + template < typename _Tp, typename _Alloc> struct _Vector_base + { + struct _Vector_impl + { + _Tp *_M_start; + }; + public: + _Vector_impl _M_impl; + }; + template < typename _Tp, typename _Alloc = std::allocator < _Tp > > + class vector:protected _Vector_base < _Tp,_Alloc > + { + public: + typedef __gnu_cxx::__normal_iterator < typename _Alloc::pointer, + vector < _Tp, _Alloc > > iterator; + iterator end () + { + } + }; + class MantaInterface + { + }; + class RTRT + { + virtual CallbackHandle *registerTerminationCallback (CallbackBase_1Data < + MantaInterface * >*); + virtual void unregisterCallback (CallbackHandle *); + typedef vector < CallbackBase_1Data < int >*>PRCallbackMapType; + PRCallbackMapType parallelPreRenderCallbacks; + }; +} +using namespace Manta; +CallbackHandle * +RTRT::registerTerminationCallback (CallbackBase_1Data < MantaInterface * >*cb) +{ + return cb; +} + +void +RTRT::unregisterCallback (CallbackHandle * callback) +{ + { + typedef CallbackBase_1Data < int > callback_t; + callback_t *cb = static_cast < callback_t * >(callback); + find (parallelPreRenderCallbacks.end (), cb); + } +} |