summaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-10-18 22:45:01 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-10-18 22:45:01 +0000
commit7d9b7a95bc7c0a26db6dd16d494b3497b16feb32 (patch)
treeffe232c41b9160769a2a4cda43c805704a8f7105 /test/SemaTemplate
parentb5f76b264eddfb946c41aa9b2b166d2fda585c3b (diff)
Don't suppress instantiation of definitions for variables subject to explicit
instantiation declarations if they are usable from constant expressions. We are permitted to instantiate in these cases, and required to do so in order to have an initializer available for use within constant evaluation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/cxx17-inline-variables.cpp7
-rw-r--r--test/SemaTemplate/extern-templates.cpp7
2 files changed, 14 insertions, 0 deletions
diff --git a/test/SemaTemplate/cxx17-inline-variables.cpp b/test/SemaTemplate/cxx17-inline-variables.cpp
new file mode 100644
index 0000000000..c0180506be
--- /dev/null
+++ b/test/SemaTemplate/cxx17-inline-variables.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// expected-no-diagnostics
+template<bool> struct DominatorTreeBase {
+ static constexpr bool IsPostDominator = true;
+};
+extern template class DominatorTreeBase<false>;
+constexpr bool k = DominatorTreeBase<false>::IsPostDominator;
diff --git a/test/SemaTemplate/extern-templates.cpp b/test/SemaTemplate/extern-templates.cpp
index 5eb9c9db12..acbc9d5712 100644
--- a/test/SemaTemplate/extern-templates.cpp
+++ b/test/SemaTemplate/extern-templates.cpp
@@ -71,3 +71,10 @@ extern template void X1<const void*>::g(const void*);
void g_X1_2(X1<const void *> x1, const void *ptr) {
x1.g(ptr);
}
+
+namespace static_const_member {
+ template <typename T> struct A { static const int n; };
+ template <typename T> const int A<T>::n = 3;
+ extern template struct A<int>;
+ int arr[A<int>::n];
+}