summaryrefslogtreecommitdiffstats
path: root/test/CXX/dcl.decl/dcl.fct.def
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-11-11 19:30:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-11-11 19:30:41 +0000
commit1d53e9cfbcf57d0a29475da315655e3c6e53f4a2 (patch)
treec6526914d5b37fbe958462307275dd572dd7b943 /test/CXX/dcl.decl/dcl.fct.def
parentd45e22102f8702a5280f100ebf0c503d65590321 (diff)
First half of CWG1962: decltype(__func__) should not be a reference type,
because __func__ is supposed to act like a local static variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/dcl.decl/dcl.fct.def')
-rw-r--r--test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp
new file mode 100644
index 0000000000..ff5d3dec30
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+// expected-no-diagnostics
+
+using size_t = decltype(sizeof(0));
+template<typename T> struct check;
+template<size_t N> struct check<const char[N]> {};
+
+constexpr bool startswith(const char *p, const char *q) {
+ return !*q || (*p == *q && startswith(p + 1, q + 1));
+}
+constexpr bool contains(const char *p, const char *q) {
+ return *p && (startswith(p, q) || contains(p + 1, q));
+}
+
+void foo() {
+ check<decltype(__func__)>();
+ static_assert(contains(__func__, "foo"), "");
+}