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 {
|
2018-05-11 10:43:08 +08:00
|
|
|
struct apply { // expected-note{{declared as a non-template here}}
|
2009-04-01 04:07:16 +08:00
|
|
|
typedef int type;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-03-31 08:43:58 +08:00
|
|
|
template<typename MetaFun, typename T>
|
|
|
|
struct apply1 {
|
2010-03-10 19:27:22 +08:00
|
|
|
typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class '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() {
|
2010-03-10 19:27:22 +08:00
|
|
|
apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'apply1<add_reference, void>' requested here}}
|
2009-04-01 04:07:16 +08:00
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
apply1<bogus, int>::type t2; // expected-note{{in instantiation of template class 'apply1<bogus, int>' requested here}}
|
2009-04-01 02:38:02 +08:00
|
|
|
}
|
2009-04-01 04:07:16 +08:00
|
|
|
|
|
|
|
|