2013-05-16 12:30:21 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -O1 -disable-llvm-optzns %s -o - | FileCheck %s
|
|
|
|
|
|
|
|
namespace test1 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test11fIZNS_1gEvE1SEEvT_(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f(T) {}
|
|
|
|
inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test2 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define internal void @_ZN5test21fIZNS_L1gEvE1S_0EEvT_(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f(T) {}
|
|
|
|
static inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test3 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define internal void @_ZN5test31fIZNS_1gEvE1SEEvT_(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f(T) {}
|
|
|
|
void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test4 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test41fIZNS_1gILi1EEEPvvE1SEEvT_(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f(T) {}
|
|
|
|
template <int N> inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
extern template void *g<1>();
|
|
|
|
template void *g<1>();
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test5 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test51fIZNS_1gILi1EEEPvvE1S_1EEvT_(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f(T) {}
|
|
|
|
template <int N> inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
extern template void *g<1>();
|
|
|
|
void *h() { return g<1>(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test6 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test61fIZZNS_1gEvEN1S1hE_2vE1T_3EEvv(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f() {}
|
|
|
|
|
|
|
|
inline void *g() {
|
|
|
|
struct S {
|
|
|
|
void *h() {
|
|
|
|
struct T {
|
|
|
|
};
|
|
|
|
return (void *)f<T>;
|
|
|
|
}
|
|
|
|
} s;
|
|
|
|
return s.h();
|
|
|
|
}
|
|
|
|
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test7 {
|
2013-05-18 06:33:49 +08:00
|
|
|
// CHECK-DAG: define internal void @_ZN5test71fIZZNS_1gEvEN1S1hEvE1T_4EEvv(
|
2013-05-16 12:30:21 +08:00
|
|
|
template <typename T> void f() {}
|
|
|
|
|
|
|
|
void *g() {
|
|
|
|
struct S {
|
|
|
|
void *h() {
|
|
|
|
struct T {
|
|
|
|
};
|
|
|
|
return (void *)f<T>;
|
|
|
|
}
|
|
|
|
} s;
|
|
|
|
return s.h();
|
|
|
|
}
|
|
|
|
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
2013-05-18 08:33:28 +08:00
|
|
|
|
|
|
|
namespace test8 {
|
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test81fIZNS_1gEvE1SEEvT_(
|
|
|
|
template <typename T> void f(T) {}
|
|
|
|
inline void *g() {
|
|
|
|
enum S {
|
|
|
|
};
|
|
|
|
return reinterpret_cast<void *>(f<S>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
2013-05-26 01:16:20 +08:00
|
|
|
|
|
|
|
namespace test9 {
|
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN5test91fIPZNS_1gEvE1S_5EEvT_(
|
|
|
|
template <typename T> void f(T) {}
|
|
|
|
inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
return reinterpret_cast<void *>(f<S*>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test10 {
|
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN6test101fIPFZNS_1gEvE1S_6vEEEvT_(
|
|
|
|
template <typename T> void f(T) {}
|
|
|
|
inline void *g() {
|
|
|
|
struct S {
|
|
|
|
} s;
|
|
|
|
typedef S(*ftype)();
|
|
|
|
return reinterpret_cast<void *>(f<ftype>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test11 {
|
|
|
|
// CHECK-DAG: define internal void @_ZN6test111fIPFZNS_1gEvE1S_7PNS_12_GLOBAL__N_11IEEEEvT_(
|
|
|
|
namespace {
|
|
|
|
struct I {
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T> void f(T) {}
|
|
|
|
inline void *g() {
|
|
|
|
struct S {
|
|
|
|
};
|
|
|
|
typedef S(*ftype)(I * x);
|
|
|
|
return reinterpret_cast<void *>(f<ftype>);
|
|
|
|
}
|
|
|
|
void *h() { return g(); }
|
|
|
|
}
|
2013-05-27 22:50:21 +08:00
|
|
|
|
|
|
|
namespace test12 {
|
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZN6test123fooIZNS_3barIZNS_3zedEvE2S2EEPvvE2S1EEvv
|
|
|
|
template <typename T> void foo() {}
|
|
|
|
template <typename T> inline void *bar() {
|
|
|
|
enum S1 {
|
|
|
|
};
|
|
|
|
return reinterpret_cast<void *>(foo<S1>);
|
|
|
|
}
|
|
|
|
inline void *zed() {
|
|
|
|
enum S2 {
|
|
|
|
};
|
|
|
|
return reinterpret_cast<void *>(bar<S2>);
|
|
|
|
}
|
|
|
|
void *h() { return zed(); }
|
|
|
|
}
|
2013-05-28 10:22:10 +08:00
|
|
|
|
|
|
|
namespace test13 {
|
|
|
|
// CHECK-DAG: define linkonce_odr void @_ZZN6test133fooEvEN1S3barEv(
|
|
|
|
inline void *foo() {
|
|
|
|
struct S {
|
|
|
|
static void bar() {}
|
|
|
|
};
|
|
|
|
return (void *)S::bar;
|
|
|
|
}
|
|
|
|
void *zed() { return foo(); }
|
|
|
|
}
|