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