summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-09-11 18:09:10 +0000
committerReid Kleckner <rnk@google.com>2019-09-11 18:09:10 +0000
commit24de5325e9198a9213a379d612dc0fe161630f00 (patch)
treeec8d03003e3ac47e262f10b83e66462f7fe289b8 /test
parent8d0c742a43a76eec372f56595f0269f38bb08b35 (diff)
downloadclang-24de5325e9198a9213a379d612dc0fe161630f00.tar.gz
[MS] Consder constexpr globals to be inline, as in C++17
Summary: Microsoft seems to do this regardless of the language mode, so we must also do it in order to be ABI compatible. Fixes PR36125 Reviewers: thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47956 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371642 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp12
-rw-r--r--test/CXX/drs/dr7xx.cpp10
-rw-r--r--test/CodeGenCXX/ms-constexpr-static-data-member.cpp26
-rw-r--r--test/CodeGenCXX/ms-integer-static-data-members-exported.cpp2
-rw-r--r--test/CodeGenCXX/ms-integer-static-data-members.cpp3
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_in_class.cpp6
-rw-r--r--test/SemaCXX/dllexport.cpp37
-rw-r--r--test/SemaCXX/dllimport.cpp91
8 files changed, 140 insertions, 47 deletions
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 5a4c5c9a9d..f472e9213f 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++1z %s
+
+// MSVC always adopted the C++17 rule that implies that constexpr variables are
+// implicitly inline, so do the test again.
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -DMS_ABI -fsyntax-only -verify -std=c++11 %s
struct notlit { // expected-note {{not literal because}}
notlit() {}
@@ -29,7 +33,7 @@ void f2(constexpr int i) {} // expected-error {{function parameter cannot be con
struct s2 {
constexpr int mi1; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
static constexpr int mi2;
-#if __cplusplus <= 201402L
+#if __cplusplus <= 201402L && !defined(MS_ABI)
// expected-error@-2 {{requires an initializer}}
#else
// expected-error@-4 {{default initialization of an object of const}}
diff --git a/test/CXX/drs/dr7xx.cpp b/test/CXX/drs/dr7xx.cpp
index 30cc4b9abe..147560d303 100644
--- a/test/CXX/drs/dr7xx.cpp
+++ b/test/CXX/drs/dr7xx.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr705 { // dr705: yes
namespace N {
diff --git a/test/CodeGenCXX/ms-constexpr-static-data-member.cpp b/test/CodeGenCXX/ms-constexpr-static-data-member.cpp
new file mode 100644
index 0000000000..dc2c4862e9
--- /dev/null
+++ b/test/CodeGenCXX/ms-constexpr-static-data-member.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-windows-msvc %s -o - | FileCheck %s
+
+struct Foo { int x, y; };
+
+struct S {
+ // PR36125
+ static constexpr char sdm_char_array[] = "asdf";
+
+ // PR43280
+ static constexpr const char *sdm_char_ptr = "asdf";
+
+ static constexpr Foo sdm_udt{1, 2};
+};
+
+void useptr(const void *p);
+void usethem() {
+ useptr(&S::sdm_char_array);
+ useptr(&S::sdm_char_ptr);
+ useptr(&S::sdm_udt);
+}
+
+// CHECK-DAG: @"?sdm_char_array@S@@2QBDB" = linkonce_odr dso_local constant [5 x i8] c"asdf\00", comdat, align 1
+
+// CHECK-DAG: @"?sdm_char_ptr@S@@2QEBDEB" = linkonce_odr dso_local constant i8* getelementptr inbounds ([5 x i8], [5 x i8]* @"??_C@_04JIHMPGLA@asdf?$AA@", i32 0, i32 0), comdat, align 8
+
+// CHECK-DAG: @"?sdm_udt@S@@2UFoo@@B" = linkonce_odr dso_local constant %struct.Foo { i32 1, i32 2 }, comdat, align 4
diff --git a/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp b/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
index 2537361383..d01b101037 100644
--- a/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
+++ b/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-extensions %s -o - | FileCheck %s
enum Enum { zero, one, two };
diff --git a/test/CodeGenCXX/ms-integer-static-data-members.cpp b/test/CodeGenCXX/ms-integer-static-data-members.cpp
index 98414350b4..e48acbf06f 100644
--- a/test/CodeGenCXX/ms-integer-static-data-members.cpp
+++ b/test/CodeGenCXX/ms-integer-static-data-members.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-windows-msvc %s -o - | FileCheck %s
struct S {
static const int NoInit_Ref;
diff --git a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index ecdd54f35f..a16a5b54d8 100644
--- a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
-// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
-// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s -DCPP1Y
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1y -verify -fsyntax-only %s -DCPP1Y
#define CONST const
diff --git a/test/SemaCXX/dllexport.cpp b/test/SemaCXX/dllexport.cpp
index e4a312adae..953684c73a 100644
--- a/test/SemaCXX/dllexport.cpp
+++ b/test/SemaCXX/dllexport.cpp
@@ -742,7 +742,7 @@ struct MemberRedecl {
static int StaticField; // expected-note{{previous declaration is here}}
static const int StaticConstField; // expected-note{{previous declaration is here}}
- constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
};
__declspec(dllexport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllexport' attribute}}
@@ -757,7 +757,12 @@ __declspec(dllexport) void MemberRedecl::staticInlineDecl() {} // expect
__declspec(dllexport) int MemberRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllexport' attribute}}
__declspec(dllexport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllexport' attribute}}
-__declspec(dllexport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllexport' attribute}}
+#ifdef MS
+// expected-warning@+4{{attribute declaration must precede definition}}
+#else
+// expected-error@+2{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllexport' attribute}}
+#endif
+__declspec(dllexport) constexpr int MemberRedecl::ConstexprField;
#ifdef MS
struct __declspec(dllexport) ClassWithMultipleDefaultCtors {
@@ -841,7 +846,7 @@ struct MemTmplRedecl {
#if __has_feature(cxx_variable_templates)
template<typename T> static int StaticField; // expected-note{{previous declaration is here}}
template<typename T> static const int StaticConstField; // expected-note{{previous declaration is here}}
- template<typename T> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ template<typename T> constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
#endif // __has_feature(cxx_variable_templates)
};
@@ -855,7 +860,13 @@ template<typename T> __declspec(dllexport) void MemTmplRedecl::staticInli
#if __has_feature(cxx_variable_templates)
template<typename T> __declspec(dllexport) int MemTmplRedecl::StaticField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticField' cannot add 'dllexport' attribute}}
template<typename T> __declspec(dllexport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllexport' attribute}}
-template<typename T> __declspec(dllexport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllexport' attribute}}
+
+#ifdef MS
+// expected-warning@+4{{attribute declaration must precede definition}}
+#else
+// expected-error@+2{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllexport' attribute}}
+#endif
+template<typename T> __declspec(dllexport) constexpr int MemTmplRedecl::ConstexprField;
#endif // __has_feature(cxx_variable_templates)
@@ -1045,7 +1056,7 @@ struct CTMR /*ClassTmplMemberRedecl*/ {
static int StaticField; // expected-note{{previous declaration is here}}
static const int StaticConstField; // expected-note{{previous declaration is here}}
- constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(definition|declaration)}} is here}}
};
template<typename T> __declspec(dllexport) void CTMR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllexport' attribute}}
@@ -1060,7 +1071,12 @@ template<typename T> __declspec(dllexport) void CTMR<T>::staticInlineDecl
template<typename T> __declspec(dllexport) int CTMR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllexport' attribute}}
template<typename T> __declspec(dllexport) const int CTMR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllexport' attribute}}
-template<typename T> __declspec(dllexport) constexpr int CTMR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllexport' attribute}}
+#ifdef MS
+// expected-warning@+4{{attribute declaration must precede definition}}
+#else
+// expected-error@+2{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllexport' attribute}}
+#endif
+template<typename T> __declspec(dllexport) constexpr int CTMR<T>::ConstexprField;
@@ -1120,7 +1136,7 @@ struct CTMTR /*ClassTmplMemberTmplRedecl*/ {
#if __has_feature(cxx_variable_templates)
template<typename U> static int StaticField; // expected-note{{previous declaration is here}}
template<typename U> static const int StaticConstField; // expected-note{{previous declaration is here}}
- template<typename U> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ template<typename U> constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
#endif // __has_feature(cxx_variable_templates)
};
@@ -1134,7 +1150,12 @@ template<typename T> template<typename U> __declspec(dllexport) void CTMT
#if __has_feature(cxx_variable_templates)
template<typename T> template<typename U> __declspec(dllexport) int CTMTR<T>::StaticField = 1; // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllexport' attribute}}
template<typename T> template<typename U> __declspec(dllexport) const int CTMTR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllexport' attribute}}
-template<typename T> template<typename U> __declspec(dllexport) constexpr int CTMTR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllexport' attribute}}
+#ifdef MS
+// expected-warning@+4{{attribute declaration must precede definition}}
+#else
+// expected-error@+2{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllexport' attribute}}
+#endif
+template<typename T> template<typename U> __declspec(dllexport) constexpr int CTMTR<T>::ConstexprField;
#endif // __has_feature(cxx_variable_templates)
// FIXME: Precedence rules seem to be different for classes.
diff --git a/test/SemaCXX/dllimport.cpp b/test/SemaCXX/dllimport.cpp
index 73aea57ba2..80c6f2e678 100644
--- a/test/SemaCXX/dllimport.cpp
+++ b/test/SemaCXX/dllimport.cpp
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s
// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
// Helper structs to make templates more expressive.
struct ImplicitInst_Imported {};
@@ -586,7 +587,10 @@ public:
__declspec(dllimport) static const int StaticConstFieldEqualInit = 1;
__declspec(dllimport) static const int StaticConstFieldBraceInit{1};
__declspec(dllimport) constexpr static int ConstexprField = 1;
- __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}}
+#if __cplusplus < 201703L && !defined(MS)
+ // expected-note@+2{{attribute is here}}
+#endif
+ __declspec(dllimport) constexpr static int ConstexprFieldDef = 1;
};
#ifdef MS
@@ -631,7 +635,10 @@ inline void ImportMembers::staticInlineDef() {}
int ImportMembers::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}}
const int ImportMembers::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}}
-constexpr int ImportMembers::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}}
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+2{{definition of dllimport static field not allowed}}
+#endif
+constexpr int ImportMembers::ConstexprFieldDef;
// Import on member definitions.
@@ -667,7 +674,11 @@ __declspec(dllimport) void ImportMemberDefs::staticInlineDecl() {}
__declspec(dllimport) int ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
__declspec(dllimport) const int ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
-__declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+3{{definition of dllimport static field not allowed}}
+// expected-note@+2{{attribute is here}}
+#endif
+__declspec(dllimport) constexpr int ImportMemberDefs::ConstexprField;
// Import special member functions.
@@ -800,7 +811,7 @@ struct MemberRedecl {
static int StaticField; // expected-note{{previous declaration is here}}
static const int StaticConstField; // expected-note{{previous declaration is here}}
- constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
};
__declspec(dllimport) void MemberRedecl::normalDef() {} // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}}
@@ -831,9 +842,15 @@ __declspec(dllimport) int MemberRedecl::StaticField = 1; // expect
__declspec(dllimport) const int MemberRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemberRedecl::StaticConstField' cannot add 'dllimport' attribute}}
// expected-error@-1{{definition of dllimport static field not allowed}}
// expected-note@-2{{attribute is here}}
-__declspec(dllimport) constexpr int MemberRedecl::ConstexprField; // expected-error{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}}
- // expected-error@-1{{definition of dllimport static field not allowed}}
- // expected-note@-2{{attribute is here}}
+
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+6{{redeclaration of 'MemberRedecl::ConstexprField' cannot add 'dllimport' attribute}}
+// expected-error@+5{{definition of dllimport static field not allowed}}
+// expected-note@+4{{attribute is here}}
+#else
+// expected-warning@+2{{attribute declaration must precede definition}}
+#endif
+__declspec(dllimport) constexpr int MemberRedecl::ConstexprField;
@@ -875,7 +892,7 @@ struct ImportMemberTmpl {
template<typename T> __declspec(dllimport) static const int StaticConstFieldEqualInit = 1;
template<typename T> __declspec(dllimport) static const int StaticConstFieldBraceInit{1};
template<typename T> __declspec(dllimport) constexpr static int ConstexprField = 1;
- template<typename T> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}}
+ template<typename T> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1;
#endif // __has_feature(cxx_variable_templates)
};
@@ -900,7 +917,9 @@ template<typename T> inline void ImportMemberTmpl::staticInlineDef() {} // expec
#if __has_feature(cxx_variable_templates)
template<typename T> int ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}}
template<typename T> const int ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}}
-template<typename T> constexpr int ImportMemberTmpl::ConstexprFieldDef; // expected-error{{definition of dllimport static field not allowed}}
+#ifdef MS
+template<typename T> constexpr int ImportMemberTmpl::ConstexprFieldDef;
+#endif
#endif // __has_feature(cxx_variable_templates)
@@ -921,7 +940,9 @@ struct MemTmplRedecl {
#if __has_feature(cxx_variable_templates)
template<typename T> static int StaticField; // expected-note{{previous declaration is here}}
template<typename T> static const int StaticConstField; // expected-note{{previous declaration is here}}
- template<typename T> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+#ifdef MS
+ template<typename T> constexpr static int ConstexprField = 1; // expected-note{{previous definition is here}}
+#endif
#endif // __has_feature(cxx_variable_templates)
};
@@ -949,9 +970,10 @@ template<typename T> __declspec(dllimport) int MemTmplRedecl::StaticFiel
template<typename T> __declspec(dllimport) const int MemTmplRedecl::StaticConstField = 1; // expected-error{{redeclaration of 'MemTmplRedecl::StaticConstField' cannot add 'dllimport' attribute}}
// expected-error@-1{{definition of dllimport static field not allowed}}
// expected-note@-2{{attribute is here}}
-template<typename T> __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField; // expected-error{{redeclaration of 'MemTmplRedecl::ConstexprField' cannot add 'dllimport' attribute}}
- // expected-error@-1{{definition of dllimport static field not allowed}}
- // expected-note@-2{{attribute is here}}
+#ifdef MS
+// expected-warning@+1{{attribute declaration must precede definition}}
+template<typename T> __declspec(dllimport) constexpr int MemTmplRedecl::ConstexprField;
+#endif
#endif // __has_feature(cxx_variable_templates)
@@ -1159,7 +1181,10 @@ public:
__declspec(dllimport) static const int StaticConstFieldEqualInit = 1;
__declspec(dllimport) static const int StaticConstFieldBraceInit{1};
__declspec(dllimport) constexpr static int ConstexprField = 1;
- __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}}
+#if __cplusplus < 201703L && !defined(MS)
+ // expected-note@+2{{attribute is here}}
+#endif
+ __declspec(dllimport) constexpr static int ConstexprFieldDef = 1;
};
// NB: MSVC is inconsistent here and disallows *InlineDef on class templates,
@@ -1203,7 +1228,10 @@ template<typename T> void ImportClassTmplMembers<T>::staticInlineDecl() {
template<typename T> int ImportClassTmplMembers<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}}
template<typename T> const int ImportClassTmplMembers<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}}
-template<typename T> constexpr int ImportClassTmplMembers<T>::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}}
+#if __cplusplus < 201703L && !defined(MS)
+// expected-warning@+2{{definition of dllimport static field}}
+#endif
+template<typename T> constexpr int ImportClassTmplMembers<T>::ConstexprFieldDef;
// Redeclarations cannot add dllimport.
@@ -1227,7 +1255,7 @@ struct CTMR /*ClassTmplMemberRedecl*/ {
static int StaticField; // expected-note{{previous declaration is here}}
static const int StaticConstField; // expected-note{{previous declaration is here}}
- constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+ constexpr static int ConstexprField = 1; // expected-note-re{{previous {{(declaration|definition)}} is here}}
};
template<typename T> __declspec(dllimport) void CTMR<T>::normalDef() {} // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}}
@@ -1256,9 +1284,15 @@ template<typename T> __declspec(dllimport) int CTMR<T>::StaticField = 1;
template<typename T> __declspec(dllimport) const int CTMR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMR::StaticConstField' cannot add 'dllimport' attribute}}
// expected-warning@-1{{definition of dllimport static field}}
// expected-note@-2{{attribute is here}}
-template<typename T> __declspec(dllimport) constexpr int CTMR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}}
- // expected-warning@-1{{definition of dllimport static field}}
- // expected-note@-2{{attribute is here}}
+
+#if __cplusplus < 201703L && !defined(MS)
+// expected-error@+6{{redeclaration of 'CTMR::ConstexprField' cannot add 'dllimport' attribute}}
+// expected-warning@+5{{definition of dllimport static field}}
+// expected-note@+4{{attribute is here}}
+#else
+// expected-warning@+2{{attribute declaration must precede definition}}
+#endif
+template<typename T> __declspec(dllimport) constexpr int CTMR<T>::ConstexprField;
@@ -1306,7 +1340,9 @@ struct ImportClsTmplMemTmpl {
template<typename U> __declspec(dllimport) static const int StaticConstFieldEqualInit = 1;
template<typename U> __declspec(dllimport) static const int StaticConstFieldBraceInit{1};
template<typename U> __declspec(dllimport) constexpr static int ConstexprField = 1;
- template<typename U> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1; // expected-note{{attribute is here}}
+#ifdef MS
+ template<typename U> __declspec(dllimport) constexpr static int ConstexprFieldDef = 1;
+#endif
#endif // __has_feature(cxx_variable_templates)
};
@@ -1331,7 +1367,9 @@ template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::s
#if __has_feature(cxx_variable_templates)
template<typename T> template<typename U> int ImportClsTmplMemTmpl<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}}
template<typename T> template<typename U> const int ImportClsTmplMemTmpl<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}}
-template<typename T> template<typename U> constexpr int ImportClsTmplMemTmpl<T>::ConstexprFieldDef; // expected-warning{{definition of dllimport static field}}
+#ifdef MS
+template<typename T> template<typename U> constexpr int ImportClsTmplMemTmpl<T>::ConstexprFieldDef;
+#endif
#endif // __has_feature(cxx_variable_templates)
@@ -1353,7 +1391,9 @@ struct CTMTR /*ClassTmplMemberTmplRedecl*/ {
#if __has_feature(cxx_variable_templates)
template<typename U> static int StaticField; // expected-note{{previous declaration is here}}
template<typename U> static const int StaticConstField; // expected-note{{previous declaration is here}}
- template<typename U> constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
+#ifdef MS
+ template<typename U> constexpr static int ConstexprField = 1; // expected-note{{previous definition is here}}
+#endif
#endif // __has_feature(cxx_variable_templates)
};
@@ -1379,9 +1419,10 @@ template<typename T> template<typename U> __declspec(dllimport) int CTMT
template<typename T> template<typename U> __declspec(dllimport) const int CTMTR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllimport' attribute}}
// expected-warning@-1{{definition of dllimport static field}}
// expected-note@-2{{attribute is here}}
-template<typename T> template<typename U> __declspec(dllimport) constexpr int CTMTR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllimport' attribute}}
- // expected-warning@-1{{definition of dllimport static field}}
- // expected-note@-2{{attribute is here}}
+#ifdef MS
+// expected-warning@+1{{attribute declaration must precede definition}}
+template<typename T> template<typename U> __declspec(dllimport) constexpr int CTMTR<T>::ConstexprField;
+#endif
#endif // __has_feature(cxx_variable_templates)