summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/unaddressable-functions.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-03-19 21:36:10 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-03-19 21:36:10 +0000
commit3cde9bf9d5734820c1f17981fd235ed98772124a (patch)
tree80c9f2a4d458386761b81a6190bb5a1d24865bc1 /clang/test/SemaCXX/unaddressable-functions.cpp
parent43165d913aeb61e32877c0d3e9dafa3d926b8c4d (diff)
downloadbcm5719-llvm-3cde9bf9d5734820c1f17981fd235ed98772124a.tar.gz
bcm5719-llvm-3cde9bf9d5734820c1f17981fd235ed98772124a.zip
[Sema] Allow casting of some overloaded functions
Some functions can't have their address taken. If we encounter an overload set where only one of the candidates can have its address taken, we should automatically select that candidate in cast expressions. Differential Revision: http://reviews.llvm.org/D17701 llvm-svn: 263887
Diffstat (limited to 'clang/test/SemaCXX/unaddressable-functions.cpp')
-rw-r--r--clang/test/SemaCXX/unaddressable-functions.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/unaddressable-functions.cpp b/clang/test/SemaCXX/unaddressable-functions.cpp
new file mode 100644
index 00000000000..a382ccfa6cd
--- /dev/null
+++ b/clang/test/SemaCXX/unaddressable-functions.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+
+namespace access_control {
+class Private {
+ void check(int *) __attribute__((enable_if(false, "")));
+ void check(double *) __attribute__((enable_if(true, "")));
+
+ static void checkStatic(int *) __attribute__((enable_if(false, "")));
+ static void checkStatic(double *) __attribute__((enable_if(true, "")));
+};
+
+auto Priv = reinterpret_cast<void (Private::*)(char *)>(&Private::check); // expected-error{{'check' is a private member of 'access_control::Private'}} expected-note@6{{implicitly declared private here}}
+
+auto PrivStatic = reinterpret_cast<void (*)(char *)>(&Private::checkStatic); // expected-error{{'checkStatic' is a private member of 'access_control::Private'}} expected-note@9{{implicitly declared private here}}
+
+class Protected {
+protected:
+ void check(int *) __attribute__((enable_if(false, "")));
+ void check(double *) __attribute__((enable_if(true, "")));
+
+ static void checkStatic(int *) __attribute__((enable_if(false, "")));
+ static void checkStatic(double *) __attribute__((enable_if(true, "")));
+};
+
+auto Prot = reinterpret_cast<void (Protected::*)(char *)>(&Protected::check); // expected-error{{'check' is a protected member of 'access_control::Protected'}} expected-note@19{{declared protected here}}
+
+auto ProtStatic = reinterpret_cast<void (*)(char *)>(&Protected::checkStatic); // expected-error{{'checkStatic' is a protected member of 'access_control::Protected'}} expected-note@22{{declared protected here}}
+}
+
+namespace unavailable {
+// Ensure that we check that the function can be called
+void foo() __attribute__((unavailable("don't call this")));
+void foo(int) __attribute__((enable_if(false, "")));
+
+void *Ptr = reinterpret_cast<void*>(foo); // expected-error{{'foo' is unavailable: don't call this}} expected-note@-3{{explicitly marked unavailable here}}
+}
OpenPOWER on IntegriCloud