14a2a8f7fSDouglas Gregor // RUN: %clang_cc1 -fms-extensions -std=c++11 %s -verify 243edb32fSDouglas Gregor 343edb32fSDouglas Gregor struct Nontemplate { 443edb32fSDouglas Gregor typedef int type; 543edb32fSDouglas Gregor }; 643edb32fSDouglas Gregor 743edb32fSDouglas Gregor template<typename T> 843edb32fSDouglas Gregor struct X { __if_existsX943edb32fSDouglas Gregor __if_exists(Nontemplate::type) { 1043edb32fSDouglas Gregor typedef Nontemplate::type type; 1143edb32fSDouglas Gregor } 1243edb32fSDouglas Gregor __if_existsX1343edb32fSDouglas Gregor __if_exists(Nontemplate::value) { 1443edb32fSDouglas Gregor typedef Nontemplate::value type2; 1543edb32fSDouglas Gregor } 1643edb32fSDouglas Gregor __if_not_existsX1743edb32fSDouglas Gregor __if_not_exists(Nontemplate::value) { 1843edb32fSDouglas Gregor typedef int type3; 1943edb32fSDouglas Gregor } 2043edb32fSDouglas Gregor __if_existsX2143edb32fSDouglas Gregor __if_exists(T::X) { // expected-warning{{dependent __if_exists declarations are ignored}} 2243edb32fSDouglas Gregor typedef T::X type4; 2343edb32fSDouglas Gregor } 2443edb32fSDouglas Gregor }; 2543edb32fSDouglas Gregor 2643edb32fSDouglas Gregor X<int>::type i1; 2743edb32fSDouglas Gregor X<int>::type2 i2; // expected-error{{no type named 'type2' in 'X<int>'}} 2843edb32fSDouglas Gregor X<int>::type3 i3; 2943edb32fSDouglas Gregor X<int>::type4 i4; // expected-error{{no type named 'type4' in 'X<int>'}} 3043edb32fSDouglas Gregor 3143edb32fSDouglas Gregor struct HasFoo { 3243edb32fSDouglas Gregor void foo(); 3343edb32fSDouglas Gregor }; 3443edb32fSDouglas Gregor struct HasBar { 3543edb32fSDouglas Gregor void bar(int); 3643edb32fSDouglas Gregor void bar(float); 3743edb32fSDouglas Gregor }; 3843edb32fSDouglas Gregor 3943edb32fSDouglas Gregor template<typename T> f(T t)4043edb32fSDouglas Gregorvoid f(T t) { 4143edb32fSDouglas Gregor __if_exists(T::foo) { 4243edb32fSDouglas Gregor { } 4343edb32fSDouglas Gregor t.foo(); 4443edb32fSDouglas Gregor } 4543edb32fSDouglas Gregor 4643edb32fSDouglas Gregor __if_not_exists(T::bar) { 47deb4a2beSDouglas Gregor int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}} 4843edb32fSDouglas Gregor { } 4943edb32fSDouglas Gregor } 50*02513160SFrancois Pichet 51*02513160SFrancois Pichet int array2[] = { 52*02513160SFrancois Pichet 0, 53*02513160SFrancois Pichet __if_exists(T::bar) {2, }// expected-warning{{dependent __if_exists declarations are ignored}} 54*02513160SFrancois Pichet 3 55*02513160SFrancois Pichet }; 5643edb32fSDouglas Gregor } 5743edb32fSDouglas Gregor 58deb4a2beSDouglas Gregor template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}} 5943edb32fSDouglas Gregor template void f(HasBar); 604a2a8f7fSDouglas Gregor 614a2a8f7fSDouglas Gregor template<typename T, typename ...Ts> g(T,Ts...)624a2a8f7fSDouglas Gregorvoid g(T, Ts...) { 634a2a8f7fSDouglas Gregor __if_exists(T::operator Ts) { // expected-error{{__if_exists name contains unexpanded parameter pack 'Ts'}} 644a2a8f7fSDouglas Gregor } 654a2a8f7fSDouglas Gregor 664a2a8f7fSDouglas Gregor __if_not_exists(Ts::operator T) { // expected-error{{__if_not_exists name contains unexpanded parameter pack 'Ts'}} 674a2a8f7fSDouglas Gregor } 684a2a8f7fSDouglas Gregor } 69