Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives a
variable weak discardable linkage and partially-ordered initialization, and is
implied for constexpr static data members.)
llvm-svn: 273754
diff --git a/clang/test/CXX/class/class.static/class.static.data/p2.cpp b/clang/test/CXX/class/class.static/class.static.data/p2.cpp
new file mode 100644
index 0000000..8c38276
--- /dev/null
+++ b/clang/test/CXX/class/class.static/class.static.data/p2.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+struct X {
+ static struct A a;
+ static inline struct B b; // expected-error {{incomplete type}} expected-note {{forward decl}}
+ static inline struct C c = {}; // expected-error {{incomplete type}} expected-note {{forward decl}}
+};
diff --git a/clang/test/CXX/class/class.static/class.static.data/p3.cpp b/clang/test/CXX/class/class.static/class.static.data/p3.cpp
index 1607bac..413017d 100644
--- a/clang/test/CXX/class/class.static/class.static.data/p3.cpp
+++ b/clang/test/CXX/class/class.static/class.static.data/p3.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
struct NonLit { // expected-note 3{{no constexpr constructors}}
NonLit();
@@ -6,7 +7,7 @@
struct S {
static constexpr int a = 0;
- static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
+ static constexpr int b; // expected-error {{initializ}} expected-note 0-1{{previous}}
static constexpr int c = 0;
static const int d;
@@ -16,19 +17,27 @@
static const double f = 0.0; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
static char *const g = 0; // expected-error {{requires 'constexpr' specifier}}
static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}}
+
+ static inline int i; // expected-note {{previous}} expected-warning 0-1{{extension}}
+ static inline int j; // expected-note {{previous}} expected-warning 0-1{{extension}}
+ static constexpr int k = 0;
};
constexpr int S::a;
-constexpr int S::b = 0;
+constexpr int S::b = 0; // expected-error 0-1{{redefinition}}
const int S::c;
constexpr int S::d = 0;
constexpr int S::d2;
+int S::i; // expected-error {{redefinition}}
+int S::j; // expected-error {{redefinition}}
+const int S::k; // ok (deprecated)
+
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 int b; // expected-error {{initializ}}
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;