2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
template<typename Signature>
|
|
|
|
class C;
|
|
|
|
|
|
|
|
template<typename Ret>
|
|
|
|
class C<Ret(void)> {};
|
|
|
|
typedef C<void(void)> C0;
|
|
|
|
|
|
|
|
template<typename Ret, typename Arg1>
|
|
|
|
class C<Ret(Arg1)> {};
|
|
|
|
|
|
|
|
template<typename Ret, typename Arg1, typename Arg2>
|
|
|
|
class C<Ret(Arg1, Arg2)> {};
|
|
|
|
|
|
|
|
C0 callback_void;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_void@@3V?$C@$$A6AXXZ@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
volatile C0 callback_void_volatile;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_void_volatile@@3V?$C@$$A6AXXZ@@C"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
class Type {};
|
|
|
|
|
|
|
|
C<int(void)> callback_int;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_int@@3V?$C@$$A6AHXZ@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
C<Type(void)> callback_Type;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_Type@@3V?$C@$$A6A?AVType@@XZ@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
C<void(int)> callback_void_int;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_void_int@@3V?$C@$$A6AXH@Z@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
C<int(int)> callback_int_int;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_int_int@@3V?$C@$$A6AHH@Z@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
C<void(Type)> callback_void_Type;
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?callback_void_Type@@3V?$C@$$A6AXVType@@@Z@@A"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
void foo(C0 c) {}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?foo@@YAXV?$C@$$A6AXXZ@@@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
// Here be dragons!
|
|
|
|
// Let's face the magic of template partial specialization...
|
|
|
|
|
|
|
|
void function(C<void(void)>) {}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?function@@YAXV?$C@$$A6AXXZ@@@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
template<typename Ret> class C<Ret(*)(void)> {};
|
|
|
|
void function_pointer(C<void(*)(void)>) {}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?function_pointer@@YAXV?$C@P6AXXZ@@@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
// Block equivalent to the previous definitions.
|
|
|
|
template<typename Ret> class C<Ret(^)(void)> {};
|
|
|
|
void block(C<void(^)(void)>) {}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?block@@YAXV?$C@P_EAXXZ@@@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
// FYI blocks are not present in MSVS, so we're free to choose the spec.
|
|
|
|
|
|
|
|
template<typename T> class C<void (T::*)(void)> {};
|
|
|
|
class Z {
|
|
|
|
public:
|
|
|
|
void method() {}
|
|
|
|
};
|
|
|
|
void member_pointer(C<void (Z::*)(void)>) {}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "?member_pointer@@YAXV?$C@P8Z@@AEXXZ@@@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
template<typename T> void bar(T) {}
|
|
|
|
|
|
|
|
void call_bar() {
|
|
|
|
bar<int (*)(int)>(0);
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "??$bar@P6AHH@Z@@YAXP6AHH@Z@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
|
|
|
|
bar<int (^)(int)>(0);
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: "??$bar@P_EAHH@Z@@YAXP_EAHH@Z@Z"
|
2012-08-25 09:12:56 +08:00
|
|
|
// FYI blocks are not present in MSVS, so we're free to choose the spec.
|
|
|
|
}
|
2014-02-06 02:59:38 +08:00
|
|
|
|
|
|
|
template <void (*Fn)()> void WrapFnPtr() { Fn(); }
|
|
|
|
template <void (&Fn)()> void WrapFnRef() { Fn(); }
|
|
|
|
struct Thing {
|
|
|
|
static void VoidStaticMethod();
|
|
|
|
};
|
|
|
|
void VoidFn();
|
|
|
|
void CallWrapper() {
|
|
|
|
WrapFnPtr<VoidFn>();
|
|
|
|
WrapFnRef<VoidFn>();
|
|
|
|
WrapFnPtr<Thing::VoidStaticMethod>();
|
|
|
|
WrapFnRef<Thing::VoidStaticMethod>();
|
|
|
|
}
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call {{.*}} @"??$WrapFnPtr@$1?VoidFn@@YAXXZ@@YAXXZ"
|
|
|
|
// CHECK: call {{.*}} @"??$WrapFnRef@$1?VoidFn@@YAXXZ@@YAXXZ"
|
|
|
|
// CHECK: call {{.*}} @"??$WrapFnPtr@$1?VoidStaticMethod@Thing@@SAXXZ@@YAXXZ"
|
|
|
|
// CHECK: call {{.*}} @"??$WrapFnRef@$1?VoidStaticMethod@Thing@@SAXXZ@@YAXXZ"
|