2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-03-31 08:43:58 +08:00
|
|
|
|
|
|
|
struct add_pointer {
|
|
|
|
template<typename T>
|
|
|
|
struct apply {
|
|
|
|
typedef T* type;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct add_reference {
|
|
|
|
template<typename T>
|
|
|
|
struct apply {
|
2009-04-01 02:38:02 +08:00
|
|
|
typedef T& type; // expected-error{{cannot form a reference to 'void'}}
|
2009-03-31 08:43:58 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-04-01 04:07:16 +08:00
|
|
|
struct bogus {
|
|
|
|
struct apply {
|
|
|
|
typedef int type;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-03-31 08:43:58 +08:00
|
|
|
template<typename MetaFun, typename T>
|
|
|
|
struct apply1 {
|
2009-04-01 04:07:16 +08:00
|
|
|
typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class 'struct add_reference::apply<void>' requested here}} \
|
2009-06-13 12:51:30 +08:00
|
|
|
// expected-error{{'apply' following the 'template' keyword does not refer to a template}}
|
2009-03-31 08:43:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
apply1<add_pointer, int>::type ip = &i;
|
|
|
|
apply1<add_reference, int>::type ir = i;
|
2009-12-17 00:54:16 +08:00
|
|
|
apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
|
2009-04-01 02:38:02 +08:00
|
|
|
|
|
|
|
void test() {
|
2009-12-19 08:35:18 +08:00
|
|
|
apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'struct apply1<struct add_reference, void>' requested here}}
|
2009-04-01 04:07:16 +08:00
|
|
|
|
2009-12-19 08:35:18 +08:00
|
|
|
apply1<bogus, int>::type t2; // expected-note{{in instantiation of template class 'struct apply1<struct bogus, int>' requested here}}
|
2009-04-01 02:38:02 +08:00
|
|
|
}
|
2009-04-01 04:07:16 +08:00
|
|
|
|
|
|
|
|