1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li struct add_pointer { 4*67e74705SXin Li template<typename T> 5*67e74705SXin Li struct apply { 6*67e74705SXin Li typedef T* type; 7*67e74705SXin Li }; 8*67e74705SXin Li }; 9*67e74705SXin Li 10*67e74705SXin Li struct add_reference { 11*67e74705SXin Li template<typename T> 12*67e74705SXin Li struct apply { 13*67e74705SXin Li typedef T& type; // expected-error{{cannot form a reference to 'void'}} 14*67e74705SXin Li }; 15*67e74705SXin Li }; 16*67e74705SXin Li 17*67e74705SXin Li struct bogus { 18*67e74705SXin Li struct apply { 19*67e74705SXin Li typedef int type; 20*67e74705SXin Li }; 21*67e74705SXin Li }; 22*67e74705SXin Li 23*67e74705SXin Li template<typename MetaFun, typename T> 24*67e74705SXin Li struct apply1 { 25*67e74705SXin Li typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class 'add_reference::apply<void>' requested here}} \ 26*67e74705SXin Li // expected-error{{'apply' following the 'template' keyword does not refer to a template}} 27*67e74705SXin Li }; 28*67e74705SXin Li 29*67e74705SXin Li int i; 30*67e74705SXin Li apply1<add_pointer, int>::type ip = &i; 31*67e74705SXin Li apply1<add_reference, int>::type ir = i; 32*67e74705SXin Li 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'}} 33*67e74705SXin Li test()34*67e74705SXin Livoid test() { 35*67e74705SXin Li apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'apply1<add_reference, void>' requested here}} 36*67e74705SXin Li 37*67e74705SXin Li apply1<bogus, int>::type t2; // expected-note{{in instantiation of template class 'apply1<bogus, int>' requested here}} 38*67e74705SXin Li } 39*67e74705SXin Li 40*67e74705SXin Li 41