summaryrefslogtreecommitdiffstats
path: root/test/CXX/temp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/temp')
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp11
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp10
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp2
3 files changed, 15 insertions, 8 deletions
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
index 59ce8b6..3f65466 100644
--- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
+++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
@@ -1,19 +1,23 @@
-// RUN: %clang_cc1 -std=c++11 %s -verify
+// RUN: %clang_cc1 -std=c++11 %s -verify -triple x86_64-linux-gnu
namespace std {
typedef decltype(nullptr) nullptr_t;
}
-template<int *ip> struct IP { // expected-note 4 {{template parameter is declared here}}
+template<int *ip> struct IP { // expected-note 5 {{template parameter is declared here}}
IP<ip> *ip2;
};
+template<int &ip> struct IR {};
+
constexpr std::nullptr_t get_nullptr() { return nullptr; }
constexpr std::nullptr_t np = nullptr;
std::nullptr_t nonconst_np; // expected-note{{declared here}}
+thread_local int tl; // expected-note {{refers here}}
+
IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
IP<nullptr> ip2;
@@ -23,6 +27,9 @@ IP<np> ip5;
IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \
// expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}}
IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}}
+IP<&tl> ip7; // expected-error{{non-type template argument of type 'int *' is not a constant expression}}
+
+IR<tl> ir1; // expected-error{{non-type template argument refers to thread-local object}}
struct X { };
template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}}
diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
index e0ffef5..82114cf 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
@@ -193,18 +193,18 @@ namespace PacksAtDifferentLevels {
template<typename...A>
struct X6 {
template<typename...B>
- constexpr auto f1(A ...a) -> decltype(g(A(a + B())...)) { return g(A(a + B())...); }
+ constexpr auto f1(A ...a) const -> decltype(g(A(a + B())...)) { return g(A(a + B())...); }
template<typename...B>
- constexpr auto f2(A ...a, B ...b) -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}}
+ constexpr auto f2(A ...a, B ...b) const -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}}
template<typename...B> struct Inner {
template<typename...C>
- constexpr auto f(A ...a, B ...b, C ...c) -> decltype(g(a+b+c...)) { return g(a+b+c...); }
+ constexpr auto f(A ...a, B ...b, C ...c) const -> decltype(g(a+b+c...)) { return g(a+b+c...); }
};
};
- struct A { constexpr operator int() { return 2; } };
- struct B { constexpr operator int() { return 1; } };
+ struct A { constexpr operator int() const { return 2; } };
+ struct B { constexpr operator int() const { return 1; } };
static_assert(X6<unsigned char, int>().f1<A, B>(255, 1) == 12, "");
static_assert(X6<int, int>().f2(3, 4, 0, 0) == 34, "");
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
index e0c7b35..f804d4d 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -9,7 +9,7 @@ template inline void X<int>::f(); // expected-error{{explicit instantiation cann
template<typename T>
struct Y {
- constexpr int f() { return 0; }
+ constexpr int f() { return 0; } // expected-warning{{C++1y}}
};
template constexpr int Y<int>::f() const; // expected-error{{explicit instantiation cannot be 'constexpr'}}
OpenPOWER on IntegriCloud