summaryrefslogtreecommitdiffstats
path: root/clang/test/PCH/ms-if-exists.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-25 01:33:02 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-25 01:33:02 +0000
commitdeb4a2be6742e9457e639548a05615c9674c22d4 (patch)
tree6d51e5336be7c931aed6c37a45227e981d076a87 /clang/test/PCH/ms-if-exists.cpp
parent4223b3b380d11a86d64ff370bf2742961d5d9fff (diff)
downloadbcm5719-llvm-deb4a2be6742e9457e639548a05615c9674c22d4.tar.gz
bcm5719-llvm-deb4a2be6742e9457e639548a05615c9674c22d4.zip
Implement support for dependent Microsoft __if_exists/__if_not_exists
statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
Diffstat (limited to 'clang/test/PCH/ms-if-exists.cpp')
-rw-r--r--clang/test/PCH/ms-if-exists.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/PCH/ms-if-exists.cpp b/clang/test/PCH/ms-if-exists.cpp
new file mode 100644
index 00000000000..4bea198d9ba
--- /dev/null
+++ b/clang/test/PCH/ms-if-exists.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -include-pch %t %s -verify
+
+#ifndef HEADER
+#define HEADER
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+}
+#else
+struct HasFoo {
+ void foo();
+};
+struct HasBar {
+ void bar(int);
+ void bar(float);
+};
+
+template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
+template void f(HasBar);
+#endif
OpenPOWER on IntegriCloud