summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-07-02 01:32:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-07-02 01:32:16 +0000
commitd9b9009c611a03b47b40f780de5562b141810682 (patch)
tree8b850ec1d6b4ca2c214a840077cd0b9827d0c880 /clang/test
parent27cdf401eaa84e0d4ae82d174ddba6453e882856 (diff)
downloadbcm5719-llvm-d9b9009c611a03b47b40f780de5562b141810682.tar.gz
bcm5719-llvm-d9b9009c611a03b47b40f780de5562b141810682.zip
PR28394: For compatibility with c++11 and c++14, if a static constexpr data
member is redundantly redeclared outside the class definition in code built in c++17 mode, ensure we emit a non-discardable definition of the data member for c++11 and c++14 compilations to use. llvm-svn: 274416
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenCXX/cxx1z-inline-variables.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx1z-inline-variables.cpp b/clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
index 90d0ed61311..183709373d1 100644
--- a/clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
+++ b/clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
@@ -24,6 +24,26 @@ int a = f();
inline int b = f();
int c = f();
+// For compatibility with C++11 and C++14, an out-of-line declaration of a
+// static constexpr local variable promotes the variable to weak_odr.
+struct compat {
+ static constexpr int a = 1;
+ static constexpr int b = 2;
+ static constexpr int c = 3;
+ static inline constexpr int d = 4;
+};
+const int &compat_use_before_redecl = compat::b;
+const int compat::a;
+const int compat::b;
+const int compat::c;
+const int compat::d;
+const int &compat_use_after_redecl1 = compat::c;
+const int &compat_use_after_redecl2 = compat::d;
+// CHECK: @_ZN6compat1bE = weak_odr constant i32 2
+// CHECK: @_ZN6compat1aE = weak_odr constant i32 1
+// CHECK: @_ZN6compat1cE = weak_odr constant i32 3
+// CHECK: @_ZN6compat1dE = linkonce_odr constant i32 4
+
template<typename T> struct X {
static int a;
static inline int b;
OpenPOWER on IntegriCloud