Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 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 | #ifndef HEADER |
| 5 | #define HEADER |
| 6 | template<typename T> |
| 7 | void f(T t) { |
| 8 | __if_exists(T::foo) { |
| 9 | { } |
| 10 | t.foo(); |
| 11 | } |
| 12 | |
| 13 | __if_not_exists(T::bar) { |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 14 | int *i = t; |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 15 | { } |
| 16 | } |
| 17 | } |
| 18 | #else |
| 19 | struct HasFoo { |
| 20 | void foo(); |
| 21 | }; |
| 22 | struct HasBar { |
| 23 | void bar(int); |
| 24 | void bar(float); |
| 25 | }; |
| 26 | |
| 27 | template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}} |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 28 | // expected-error@14{{no viable conversion from 'HasFoo' to 'int *'}} |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 29 | template void f(HasBar); |
| 30 | #endif |