1 // RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -emit-pch -o %t %s
2 // RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -include-pch %t %s -verify
3 
4 // RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -emit-pch -fpch-instantiate-templates -o %t %s
5 // RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -include-pch %t %s -verify
6 
7 #ifndef HEADER
8 #define HEADER
9 template<typename T>
f(T t)10 void f(T t) {
11   __if_exists(T::foo) {
12     { }
13     t.foo();
14   }
15 
16   __if_not_exists(T::bar) {
17     int *i = t;
18     { }
19   }
20 }
21 #else
22 struct HasFoo {
23   void foo();
24 };
25 struct HasBar {
26   void bar(int);
27   void bar(float);
28 };
29 
30 template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
31                          // expected-error@17{{no viable conversion from 'HasFoo' to 'int *'}}
32 template void f(HasBar);
33 #endif
34