1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 21282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregor 31282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregortemplate <class T> T* f(int); // #1 41282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregortemplate <class T, class U> T& f(U); // #2 51282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregor 61282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregorvoid g() { 71282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregor int *ip = f<int>(1); // calls #1 81282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregor} 91282029f3d37f482bbba3c38ea9da17a78d11d40Douglas Gregor 10e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregortemplate<typename T> 11e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregorstruct identity { 12e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregor typedef T type; 13e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregor}; 14e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregor 15e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregortemplate <class T> 165c7bf42ef16dc767615bed10f3b7b3c1265314e1Douglas Gregor T* f2(int, typename identity<T>::type = 0); 17e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregortemplate <class T, class U> 185c7bf42ef16dc767615bed10f3b7b3c1265314e1Douglas Gregor T& f2(U, typename identity<T>::type = 0); 19e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregor 20e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregorvoid g2() { 215c7bf42ef16dc767615bed10f3b7b3c1265314e1Douglas Gregor int* ip = f2<int>(1); 22e73bb60de3c7c60453a86e097fc428d1cd367a42Douglas Gregor} 234e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor 244e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregortemplate<class T, class U> struct A { }; 254e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor 264e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregortemplate<class T, class U> inline int *f3( U, A<U,T>* p = 0 ); // #1 expected-note{{candidate function [with T = int, U = int]}} 274e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregortemplate< class U> inline float *f3( U, A<U,U>* p = 0 ); // #2 expected-note{{candidate function [with U = int]}} 284e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor 294e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregorvoid g3() { 304e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor float *fp = f3<int>( 42, (A<int,int>*)0 ); // Ok, picks #2. 314e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor f3<int>( 42 ); // expected-error{{call to 'f3' is ambiguous}} 324e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor 334e97586b804f6132d83cb534f16a5b6a7756e819Douglas Gregor} 34dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor 35dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregornamespace PR9006 { 36dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor struct X { 37dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor template <class Get> 38dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor int &f(char const* name, Get fget, char const* docstr = 0); 39dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor 40dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor template <class Get, class Set> 41dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor float &f(char const* name, Get fget, Set fset, char const* docstr = 0); 42dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor }; 43dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor 44dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor void test(X x) { 45dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor int &ir = x.f("blah", 0, "blah"); 46dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor } 47dfc331e04d4c6a09fb693a15fc5a57d29a198c86Douglas Gregor} 48