2010-03-02 07:49:17 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -fblocks -std=c++0x | FileCheck %s
|
2009-02-13 08:10:09 +08:00
|
|
|
struct X { };
|
|
|
|
struct Y { };
|
2009-03-08 07:57:03 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: @unmangled_variable = global
|
|
|
|
// CHECK: @_ZN1N1iE = global
|
|
|
|
// CHECK: @_ZZN1N1fEiiE1b = internal global
|
|
|
|
// CHECK: @_ZZN1N1gEvE1a = internal global
|
|
|
|
// CHECK: @_ZGVZN1N1gEvE1a = internal global
|
|
|
|
|
2010-01-24 11:04:27 +08:00
|
|
|
//CHECK: @pr5966_i = external global
|
|
|
|
//CHECK: @_ZL8pr5966_i = internal global
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define zeroext i1 @_ZplRK1YRA100_P1X
|
2009-02-13 08:10:09 +08:00
|
|
|
bool operator+(const Y&, X* (&xs)[100]) { return false; }
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f1s
|
2009-03-08 07:57:03 +08:00
|
|
|
typedef struct { int a; } s;
|
|
|
|
void f(s) { }
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f1e
|
2009-03-08 07:57:03 +08:00
|
|
|
typedef enum { foo } e;
|
|
|
|
void f(e) { }
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f1u
|
2009-03-08 07:57:03 +08:00
|
|
|
typedef union { int a; } u;
|
|
|
|
void f(u) { }
|
2009-03-11 01:07:44 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f1x
|
2009-03-11 01:07:44 +08:00
|
|
|
typedef struct { int a; } x,y;
|
|
|
|
void f(y) { }
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1fv
|
2009-04-01 08:15:23 +08:00
|
|
|
void f() { }
|
2009-04-01 08:58:25 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_ZN1N1fEv
|
2009-04-01 08:58:25 +08:00
|
|
|
namespace N { void f() { } }
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_ZN1N1N1fEv
|
2009-04-01 08:58:25 +08:00
|
|
|
namespace N { namespace N { void f() { } } }
|
2009-04-02 13:55:18 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @unmangled_function
|
2009-04-02 13:55:18 +08:00
|
|
|
extern "C" { namespace N { void unmangled_function() { } } }
|
|
|
|
|
2009-05-17 05:02:39 +08:00
|
|
|
extern "C" { namespace N { int unmangled_variable = 10; } }
|
2009-04-02 13:55:18 +08:00
|
|
|
|
2009-04-03 00:05:20 +08:00
|
|
|
namespace N { int i; }
|
2009-04-03 00:24:45 +08:00
|
|
|
|
|
|
|
namespace N { int f(int, int) { static int b; return b; } }
|
2009-04-14 02:03:33 +08:00
|
|
|
|
|
|
|
namespace N { int h(); void g() { static int a = h(); } }
|
2009-04-30 10:43:43 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1fno
|
2009-04-30 10:43:43 +08:00
|
|
|
void f(__int128_t, __uint128_t) { }
|
2009-05-16 00:09:15 +08:00
|
|
|
|
|
|
|
template <typename T> struct S1 {};
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S1IiE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S1<int>) {}
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S1IdE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S1<double>) {}
|
|
|
|
|
|
|
|
template <int N> struct S2 {};
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S2ILi100EE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S2<100>) {}
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S2ILin100EE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S2<-100>) {}
|
|
|
|
|
|
|
|
template <bool B> struct S3 {};
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S3ILb1EE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S3<true>) {}
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1f2S3ILb0EE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f(S3<false>) {}
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z2f22S3ILb1EE
|
2009-05-16 00:09:15 +08:00
|
|
|
void f2(S3<100>) {}
|
2009-05-18 01:41:20 +08:00
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1fM1SKFvvE
|
2009-05-18 01:41:20 +08:00
|
|
|
void f(void (S::*)() const) {}
|
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1fM1SFvvE
|
2009-05-18 01:41:20 +08:00
|
|
|
void f(void (S::*)()) {}
|
2009-09-17 07:53:19 +08:00
|
|
|
|
2009-09-17 11:46:43 +08:00
|
|
|
// CHECK: define void @_Z1fi
|
2009-09-17 07:53:19 +08:00
|
|
|
void f(const int) { }
|
|
|
|
|
2009-09-17 12:02:31 +08:00
|
|
|
template<typename T, typename U> void ft1(U u, T t) { }
|
|
|
|
|
|
|
|
template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
|
2009-09-17 11:46:43 +08:00
|
|
|
|
2009-09-18 10:42:01 +08:00
|
|
|
template<typename T, typename U = S1<T> > struct S4 { };
|
|
|
|
template<typename T> void ft3(S4<T>*) { }
|
|
|
|
|
2009-09-18 12:29:09 +08:00
|
|
|
namespace NS {
|
|
|
|
template<typename T> void ft1(T) { }
|
2009-09-18 10:42:01 +08:00
|
|
|
}
|
|
|
|
|
2009-09-21 09:21:10 +08:00
|
|
|
void g1() {
|
2009-09-17 12:02:31 +08:00
|
|
|
// CHECK: @_Z3ft1IidEvT0_T_
|
|
|
|
ft1<int, double>(1, 0);
|
|
|
|
|
|
|
|
// CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
|
|
|
|
ft2<char>(1, 0, 0);
|
2009-09-18 10:42:01 +08:00
|
|
|
|
|
|
|
// CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
|
|
|
|
ft3<int>(0);
|
2009-09-18 12:29:09 +08:00
|
|
|
|
|
|
|
// CHECK: @_ZN2NS3ft1IiEEvT_
|
|
|
|
NS::ft1<int>(1);
|
|
|
|
}
|
|
|
|
|
2009-09-21 09:21:10 +08:00
|
|
|
// Expressions
|
|
|
|
template<int I> struct S5 { };
|
|
|
|
|
|
|
|
template<int I> void ft4(S5<I>) { }
|
|
|
|
void g2() {
|
|
|
|
// CHECK: @_Z3ft4ILi10EEv2S5IXT_EE
|
|
|
|
ft4(S5<10>());
|
|
|
|
|
|
|
|
// CHECK: @_Z3ft4ILi20EEv2S5IXT_EE
|
|
|
|
ft4(S5<20>());
|
|
|
|
}
|
|
|
|
|
2009-09-18 12:29:09 +08:00
|
|
|
extern "C++" {
|
|
|
|
// CHECK: @_Z1hv
|
|
|
|
void h() { }
|
2009-09-18 00:12:20 +08:00
|
|
|
}
|
2009-09-18 12:29:09 +08:00
|
|
|
|
2009-09-23 01:23:30 +08:00
|
|
|
// PR5019
|
|
|
|
extern "C" { struct a { int b; }; }
|
|
|
|
|
|
|
|
// CHECK: @_Z1fP1a
|
|
|
|
int f(struct a *x) {
|
|
|
|
return x->b;
|
|
|
|
}
|
2009-09-23 04:33:31 +08:00
|
|
|
|
|
|
|
// PR5017
|
|
|
|
extern "C" {
|
|
|
|
struct Debug {
|
2009-12-22 14:36:32 +08:00
|
|
|
const Debug& operator<< (unsigned a) const { return *this; }
|
2009-09-23 04:33:31 +08:00
|
|
|
};
|
|
|
|
Debug dbg;
|
|
|
|
// CHECK: @_ZNK5DebuglsEj
|
|
|
|
int main(void) { dbg << 32 ;}
|
|
|
|
}
|
2009-09-26 10:26:02 +08:00
|
|
|
|
|
|
|
template<typename T> struct S6 {
|
|
|
|
typedef int B;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T> void ft5(typename S6<T>::B) { }
|
|
|
|
// CHECK: @_Z3ft5IiEvN2S6IT_E1BE
|
|
|
|
template void ft5<int>(int);
|
2009-09-27 04:13:56 +08:00
|
|
|
|
|
|
|
template<typename T> class A {};
|
|
|
|
|
|
|
|
namespace NS {
|
|
|
|
template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
|
|
|
|
}
|
|
|
|
|
2009-09-27 06:18:22 +08:00
|
|
|
// CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_
|
2009-09-27 04:13:56 +08:00
|
|
|
template bool NS::operator==(const ::A<char>&, const ::A<char>&);
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @_ZSteqIcEbRK1AIT_ES4_
|
|
|
|
template bool std::operator==(const ::A<char>&, const ::A<char>&);
|
|
|
|
|
2009-09-27 08:38:53 +08:00
|
|
|
struct S {
|
|
|
|
typedef int U;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T> typename T::U ft6(const T&) { return 0; }
|
|
|
|
|
|
|
|
// CHECK: @_Z3ft6I1SENT_1UERKS1_
|
|
|
|
template int ft6<S>(const S&);
|
2009-09-28 04:11:34 +08:00
|
|
|
|
|
|
|
template<typename> struct __is_scalar {
|
|
|
|
enum { __value = 1 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<bool, typename> struct __enable_if { };
|
|
|
|
|
|
|
|
template<typename T> struct __enable_if<true, T> {
|
|
|
|
typedef T __type;
|
|
|
|
};
|
|
|
|
|
|
|
|
// PR5063
|
|
|
|
template<typename T> typename __enable_if<__is_scalar<T>::__value, void>::__type ft7() { }
|
|
|
|
|
|
|
|
// CHECK: @_Z3ft7IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
|
|
|
|
template void ft7<int>();
|
|
|
|
// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
|
|
|
|
template void ft7<void*>();
|
2009-10-07 05:58:01 +08:00
|
|
|
|
|
|
|
// PR5144
|
|
|
|
extern "C" {
|
|
|
|
void extern_f(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: @extern_f
|
|
|
|
void extern_f(void) { }
|
|
|
|
|
2009-10-07 09:45:02 +08:00
|
|
|
struct S7 {
|
2009-12-05 06:33:25 +08:00
|
|
|
S7();
|
2009-10-07 09:45:02 +08:00
|
|
|
|
2009-12-05 06:33:25 +08:00
|
|
|
struct S { S(); };
|
2009-10-07 09:45:02 +08:00
|
|
|
struct {
|
|
|
|
S s;
|
|
|
|
} a;
|
|
|
|
};
|
|
|
|
|
|
|
|
// PR5139
|
2010-02-19 05:31:48 +08:00
|
|
|
// CHECK: @_ZN2S7C1Ev
|
2009-10-07 09:45:02 +08:00
|
|
|
// CHECK: @_ZN2S7C2Ev
|
|
|
|
// CHECK: @"_ZN2S73$_0C1Ev"
|
|
|
|
S7::S7() {}
|
|
|
|
|
2009-11-06 10:50:19 +08:00
|
|
|
// PR5063
|
|
|
|
template<typename T> typename __enable_if<(__is_scalar<T>::__value), void>::__type ft8() { }
|
|
|
|
// CHECK: @_Z3ft8IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
|
|
|
|
template void ft8<int>();
|
|
|
|
// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
|
|
|
|
template void ft8<void*>();
|
2009-12-14 09:45:37 +08:00
|
|
|
|
2009-12-16 13:48:46 +08:00
|
|
|
// PR5796
|
|
|
|
namespace PR5796 {
|
|
|
|
template<typename> struct __is_scalar {
|
|
|
|
enum { __value = 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template<bool, typename> struct __enable_if {};
|
|
|
|
template<typename T> struct __enable_if<true, T> { typedef T __type; };
|
|
|
|
template<typename T>
|
|
|
|
|
|
|
|
// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsrNS_11__is_scalarIT_EE7__valueEvE6__typeEv
|
|
|
|
typename __enable_if<!__is_scalar<T>::__value, void>::__type __fill_a() { };
|
|
|
|
|
|
|
|
void f() { __fill_a<int>(); }
|
|
|
|
}
|
|
|
|
|
2009-12-14 09:45:37 +08:00
|
|
|
namespace Expressions {
|
|
|
|
// Unary operators.
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN11Expressions2f1ILi1EEEvPAplngT_Li2E_i
|
2009-12-14 09:45:37 +08:00
|
|
|
template <int i> void f1(int (*)[(-i) + 2]) { };
|
|
|
|
template void f1<1>(int (*)[1]);
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN11Expressions2f2ILi1EEEvPApsT__i
|
2009-12-14 09:45:37 +08:00
|
|
|
template <int i> void f2(int (*)[+i]) { };
|
|
|
|
template void f2<1>(int (*)[1]);
|
|
|
|
|
|
|
|
// Binary operators.
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN11Expressions2f3ILi1EEEvPAplT_T__i
|
2009-12-14 09:45:37 +08:00
|
|
|
template <int i> void f3(int (*)[i+i]) { };
|
|
|
|
template void f3<1>(int (*)[2]);
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN11Expressions2f4ILi1EEEvPAplplLi2ET_T__i
|
2009-12-14 09:45:37 +08:00
|
|
|
template <int i> void f4(int (*)[2 + i+i]) { };
|
|
|
|
template void f4<1>(int (*)[4]);
|
|
|
|
|
|
|
|
// The ternary operator.
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN11Expressions2f4ILb1EEEvPAquT_Li1ELi2E_i
|
2009-12-14 09:45:37 +08:00
|
|
|
template <bool b> void f4(int (*)[b ? 1 : 2]) { };
|
|
|
|
template void f4<true>(int (*)[1]);
|
|
|
|
}
|
2009-12-22 14:36:32 +08:00
|
|
|
|
|
|
|
struct Ops {
|
|
|
|
Ops& operator+(const Ops&);
|
|
|
|
Ops& operator-(const Ops&);
|
|
|
|
Ops& operator&(const Ops&);
|
|
|
|
Ops& operator*(const Ops&);
|
|
|
|
|
|
|
|
void *v;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: define %struct.Ops* @_ZN3OpsplERKS_
|
|
|
|
Ops& Ops::operator+(const Ops&) { return *this; }
|
|
|
|
// CHECK: define %struct.Ops* @_ZN3OpsmiERKS_
|
|
|
|
Ops& Ops::operator-(const Ops&) { return *this; }
|
|
|
|
// CHECK: define %struct.Ops* @_ZN3OpsanERKS_
|
|
|
|
Ops& Ops::operator&(const Ops&) { return *this; }
|
|
|
|
// CHECK: define %struct.Ops* @_ZN3OpsmlERKS_
|
|
|
|
Ops& Ops::operator*(const Ops&) { return *this; }
|
|
|
|
|
2009-12-24 03:30:55 +08:00
|
|
|
// PR5861
|
|
|
|
namespace PR5861 {
|
|
|
|
template<bool> class P;
|
|
|
|
template<> class P<true> {};
|
|
|
|
|
|
|
|
template<template <bool> class, bool>
|
|
|
|
struct Policy { };
|
|
|
|
|
|
|
|
template<typename T, typename = Policy<P, true> > class Alloc
|
|
|
|
{
|
|
|
|
T *allocate(int, const void*) { return 0; }
|
|
|
|
};
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr i8* @_ZN6PR58615AllocIcNS_6PolicyINS_1PELb1EEEE8allocateEiPKv
|
2009-12-24 03:30:55 +08:00
|
|
|
template class Alloc<char>;
|
|
|
|
}
|
2009-12-24 06:31:44 +08:00
|
|
|
|
|
|
|
// CHECK: define void @_Z1fU13block_pointerFiiiE
|
2010-01-07 17:36:51 +08:00
|
|
|
void f(int (^)(int, int)) { }
|
|
|
|
|
2010-01-24 11:04:27 +08:00
|
|
|
void pr5966_foo() {
|
|
|
|
extern int pr5966_i;
|
|
|
|
pr5966_i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pr5966_i;
|
|
|
|
|
|
|
|
void pr5966_bar() {
|
|
|
|
pr5966_i = 0;
|
|
|
|
}
|
2010-02-04 09:42:13 +08:00
|
|
|
|
|
|
|
namespace test0 {
|
|
|
|
int ovl(int x);
|
|
|
|
char ovl(double x);
|
|
|
|
|
|
|
|
template <class T> void f(T, char (&buffer)[sizeof(ovl(T()))]) {}
|
|
|
|
|
|
|
|
void test0() {
|
|
|
|
char buffer[1];
|
|
|
|
f(0.0, buffer);
|
|
|
|
}
|
|
|
|
// CHECK: define void @_ZN5test05test0Ev()
|
|
|
|
// CHECK: define linkonce_odr void @_ZN5test01fIdEEvT_RAszcl3ovlcvS1__EE_c(
|
|
|
|
|
|
|
|
void test1() {
|
|
|
|
char buffer[sizeof(int)];
|
|
|
|
f(1, buffer);
|
|
|
|
}
|
|
|
|
// CHECK: define void @_ZN5test05test1Ev()
|
|
|
|
// CHECK: define linkonce_odr void @_ZN5test01fIiEEvT_RAszcl3ovlcvS1__EE_c(
|
|
|
|
|
|
|
|
template <class T> void g(char (&buffer)[sizeof(T() + 5.0f)]) {}
|
|
|
|
void test2() {
|
|
|
|
char buffer[sizeof(float)];
|
|
|
|
g<float>(buffer);
|
|
|
|
}
|
|
|
|
// CHECK: define linkonce_odr void @_ZN5test01gIfEEvRAszplcvT__ELf40A00000E_c(
|
|
|
|
|
|
|
|
template <class T> void h(char (&buffer)[sizeof(T() + 5.0)]) {}
|
|
|
|
void test3() {
|
|
|
|
char buffer[sizeof(double)];
|
|
|
|
h<float>(buffer);
|
|
|
|
}
|
|
|
|
// CHECK: define linkonce_odr void @_ZN5test01hIfEEvRAszplcvT__ELd4014000000000000E_c(
|
2010-02-04 10:56:29 +08:00
|
|
|
|
|
|
|
template <class T> void j(char (&buffer)[sizeof(T().buffer)]) {}
|
|
|
|
struct A { double buffer[128]; };
|
|
|
|
void test4() {
|
|
|
|
char buffer[1024];
|
|
|
|
j<A>(buffer);
|
|
|
|
}
|
2010-03-02 03:12:25 +08:00
|
|
|
// CHECK: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
|
2010-02-04 09:42:13 +08:00
|
|
|
}
|
2010-02-06 04:45:00 +08:00
|
|
|
|
|
|
|
namespace test1 {
|
|
|
|
template<typename T> struct X { };
|
|
|
|
template<template<class> class Y, typename T> void f(Y<T>) { }
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN5test11fINS_1XEiEEvT_IT0_E
|
2010-02-06 04:45:00 +08:00
|
|
|
template void f(X<int>);
|
|
|
|
}
|
2010-02-06 12:52:27 +08:00
|
|
|
|
|
|
|
// CHECK: define internal void @_Z27functionWithInternalLinkagev()
|
|
|
|
static void functionWithInternalLinkage() { }
|
|
|
|
void g() { functionWithInternalLinkage(); }
|
2010-03-02 07:49:17 +08:00
|
|
|
|
|
|
|
namespace test2 {
|
|
|
|
template <class T> decltype(((T*) 0)->member) read_member(T& obj) {
|
|
|
|
return obj.member;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct A { int member; } obj;
|
|
|
|
int test() {
|
|
|
|
return read_member(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: define linkonce_odr i32 @_ZN5test211read_memberINS_1AEEEDtptcvPT_Li0E6memberERS2_(
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace test3 {
|
|
|
|
struct AmbiguousBase { int ab; };
|
|
|
|
struct Path1 : AmbiguousBase { float p; };
|
|
|
|
struct Path2 : AmbiguousBase { double p; };
|
|
|
|
struct Derived : Path1, Path2 { };
|
|
|
|
|
|
|
|
//template <class T> decltype(((T*) 0)->Path1::ab) get_ab_1(T &ref) { return ref.Path1::ab; }
|
|
|
|
//template <class T> decltype(((T*) 0)->Path2::ab) get_ab_2(T &ref) { return ref.Path2::ab; }
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// define weak_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0E5Path11pERS2_(
|
2010-03-02 07:49:17 +08:00
|
|
|
template <class T> decltype(((T*) 0)->Path1::p) get_p_1(T &ref) { return ref.Path1::p; }
|
|
|
|
|
2010-03-14 02:23:07 +08:00
|
|
|
// define weak_odr double @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0E5Path21pERS2_(
|
2010-03-02 07:49:17 +08:00
|
|
|
template <class T> decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; }
|
|
|
|
|
|
|
|
Derived obj;
|
|
|
|
void test() {
|
|
|
|
// FIXME: uncomment these when we support diamonds competently
|
|
|
|
//get_ab_1(obj);
|
|
|
|
//get_ab_2(obj);
|
|
|
|
get_p_1(obj);
|
|
|
|
get_p_2(obj);
|
|
|
|
}
|
|
|
|
}
|
2010-03-11 22:07:00 +08:00
|
|
|
|
|
|
|
// CHECK: define void @_ZN5test41gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
|
|
|
|
namespace test4 {
|
|
|
|
struct foo { int bar; };
|
|
|
|
template <int (foo::*)>
|
|
|
|
struct zed {};
|
|
|
|
void g(zed<&foo::bar>*)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
// CHECK: define void @_ZN5test51gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
|
|
|
|
namespace test5 {
|
|
|
|
struct foo { static int bar; };
|
|
|
|
template <int *>
|
|
|
|
struct zed {};
|
|
|
|
void g(zed<&foo::bar>*)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
// CHECK: define void @_ZN5test61gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
|
|
|
|
namespace test6 {
|
|
|
|
struct foo { int bar(); };
|
|
|
|
template <int (foo::*)()>
|
|
|
|
struct zed {};
|
|
|
|
void g(zed<&foo::bar>*)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
// CHECK: define void @_ZN5test71gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
|
|
|
|
namespace test7 {
|
|
|
|
struct foo { static int bar(); };
|
|
|
|
template <int (*f)()>
|
|
|
|
struct zed {};
|
|
|
|
void g(zed<&foo::bar>*)
|
|
|
|
{}
|
|
|
|
}
|
2010-03-14 02:23:07 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN5test81AILZNS_1B5valueEEE3incEv
|
2010-03-11 22:07:00 +08:00
|
|
|
namespace test8 {
|
|
|
|
template <int &counter> class A { void inc() { counter++; } };
|
2010-04-10 03:03:51 +08:00
|
|
|
class B { public: static int value; };
|
2010-03-11 22:07:00 +08:00
|
|
|
template class A<B::value>;
|
|
|
|
}
|
2010-03-17 12:28:11 +08:00
|
|
|
// CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE
|
|
|
|
namespace test9 {
|
|
|
|
template<class T>
|
|
|
|
struct foo {
|
|
|
|
typedef T X;
|
|
|
|
};
|
|
|
|
struct bar {
|
|
|
|
typedef foo<int> baz;
|
|
|
|
};
|
|
|
|
template <class zaz, class zed>
|
|
|
|
void f(const typename zed::baz::X&);
|
|
|
|
void g() {
|
|
|
|
f<int, bar>( 0);
|
|
|
|
}
|
|
|
|
}
|
2010-04-10 05:48:08 +08:00
|
|
|
|
|
|
|
// <rdar://problem/7825453>
|
|
|
|
namespace test10 {
|
|
|
|
template <char P1> struct S {};
|
|
|
|
template <char P2> void f(struct S<false ? 'a' : P2> ) {}
|
|
|
|
|
|
|
|
// CHECK: define weak_odr void @_ZN6test101fILc3EEEvNS_1SIXquLb0ELc97ET_EEE(
|
|
|
|
template void f<(char) 3>(struct S<3>);
|
|
|
|
}
|
2010-06-02 12:40:13 +08:00
|
|
|
|
|
|
|
namespace test11 {
|
|
|
|
// CHECK: @_ZN6test111fEz
|
|
|
|
void f(...) { }
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
void f(...);
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: @_ZN6test111A1fEz
|
|
|
|
void A::f(...) { }
|
|
|
|
}
|
2010-06-02 13:07:26 +08:00
|
|
|
|
|
|
|
namespace test12 {
|
|
|
|
|
|
|
|
// CHECK: _ZN6test121fENS_1AILt33000EEE
|
|
|
|
template <unsigned short> struct A { };
|
|
|
|
void f(A<33000>) { }
|
2010-07-14 14:43:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// PR7446
|
|
|
|
namespace test13 {
|
|
|
|
template <template <class> class T> class A {};
|
|
|
|
template <class U> class B {};
|
|
|
|
|
|
|
|
template <template<class> class T> void foo(const A<T> &a) {}
|
|
|
|
|
|
|
|
// CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE(
|
|
|
|
template void foo(const A<B> &a);
|
|
|
|
}
|