summaryrefslogtreecommitdiffstats
path: root/test/CXX/class/class.static/class.static.data/p3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/class/class.static/class.static.data/p3.cpp')
-rw-r--r--test/CXX/class/class.static/class.static.data/p3.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/CXX/class/class.static/class.static.data/p3.cpp b/test/CXX/class/class.static/class.static.data/p3.cpp
index 007e416..117997e 100644
--- a/test/CXX/class/class.static/class.static.data/p3.cpp
+++ b/test/CXX/class/class.static/class.static.data/p3.cpp
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-struct NonLit {
+struct NonLit { // expected-note 3{{no constexpr constructors}}
NonLit();
};
struct S {
static constexpr int a = 0;
- static constexpr int b; // expected-error {{declaration of constexpr variable 'b' requires an initializer}}
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
static constexpr int c = 0;
static const int d;
@@ -24,3 +24,21 @@ constexpr int S::b = 0;
const int S::c;
constexpr int S::d = 0;
constexpr int S::d2;
+
+template<typename T>
+struct U {
+ static constexpr int a = 0;
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
+ static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}}
+ static constexpr T c = T(); // expected-error {{cannot have non-literal type}}
+ static const T d;
+};
+
+template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}}
+
+U<int> u1;
+U<NonLit> u2; // expected-note {{here}}
+
+static_assert(U<int>::a == 0, "");
+
+constexpr int outofline = (U<NonLit>::d, 0); // expected-note {{here}} expected-warning {{unused}}
OpenPOWER on IntegriCloud