summaryrefslogtreecommitdiffstats
path: root/test/CXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-04-26 01:51:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-04-26 01:51:08 +0000
commit4241f674da3531d69abc759d727fb0ae7b31535e (patch)
treedb002fa46a5290962a5858d53bd2dd4c951c97c6 /test/CXX
parent6035bca43a7fa17c8650b4611debda472f4c8754 (diff)
C++ DR2387: a variable template declared wtih (or instantiated with) a
const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. This reinstates part of r359048, reverted in r359076. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r--test/CXX/drs/dr23xx.cpp26
-rw-r--r--test/CXX/module/module.interface/p3.cpp2
-rw-r--r--test/CXX/module/module.interface/p5.cpp6
3 files changed, 30 insertions, 4 deletions
diff --git a/test/CXX/drs/dr23xx.cpp b/test/CXX/drs/dr23xx.cpp
new file mode 100644
index 0000000000..87db0d4c9b
--- /dev/null
+++ b/test/CXX/drs/dr23xx.cpp
@@ -0,0 +1,26 @@
+// 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
+
+#if __cplusplus <= 201103L
+// expected-no-diagnostics
+#endif
+
+namespace dr2387 { // dr2387: 9
+#if __cplusplus >= 201402L
+ template<int> int a = 0;
+ extern template int a<0>; // ok
+
+ template<int> static int b = 0;
+ extern template int b<0>; // expected-error {{internal linkage}}
+
+ template<int> const int c = 0;
+ extern template const int c<0>; // ok, has external linkage despite 'const'
+
+ template<typename T> T d = 0;
+ extern template int d<int>;
+ extern template const int d<const int>;
+#endif
+}
diff --git a/test/CXX/module/module.interface/p3.cpp b/test/CXX/module/module.interface/p3.cpp
index 2bf1f334e1..29d2cb43b4 100644
--- a/test/CXX/module/module.interface/p3.cpp
+++ b/test/CXX/module/module.interface/p3.cpp
@@ -48,7 +48,7 @@ export namespace { int c; } // expected-error {{declaration of 'c' with internal
namespace { // expected-note {{here}}
export int d; // expected-error {{export declaration appears within anonymous namespace}}
}
-export template<typename> static int e; // FIXME
+export template<typename> static int e; // expected-error {{declaration of 'e' with internal linkage cannot be exported}}
export template<typename> static int f(); // expected-error {{declaration of 'f' with internal linkage cannot be exported}}
export const int k = 5;
export static union { int n; }; // expected-error {{declaration of 'n' with internal linkage cannot be exported}}
diff --git a/test/CXX/module/module.interface/p5.cpp b/test/CXX/module/module.interface/p5.cpp
index c4299dc04f..17c4105baa 100644
--- a/test/CXX/module/module.interface/p5.cpp
+++ b/test/CXX/module/module.interface/p5.cpp
@@ -14,7 +14,7 @@ static union { int sg1, sg2; }; // expected-note {{target}}
namespace NS {}
template<typename> int ta;
-template<typename> static int sta;
+template<typename> static int sta; // expected-note {{target}}
template<typename> void tb();
template<typename> static void stb(); // expected-note {{target}}
template<typename> struct tc {};
@@ -44,7 +44,7 @@ namespace UnnamedNS {
}
}
-export { // expected-note 18{{here}}
+export { // expected-note 19{{here}}
using ::a;
using ::sa; // expected-error {{using declaration referring to 'sa' with internal linkage}}
using ::b;
@@ -56,7 +56,7 @@ export { // expected-note 18{{here}}
using ::sg1; // expected-error {{using declaration referring to 'sg1' with internal linkage}}
using ::ta;
- using ::sta; // FIXME {{using declaration referring to 'sta' with internal linkage}}
+ using ::sta; // expected-error {{using declaration referring to 'sta' with internal linkage}}
using ::tb;
using ::stb; // expected-error {{using declaration referring to 'stb' with internal linkage}}
using ::tc;