Clang Project

clang_source_code/test/SemaTemplate/cxx17-inline-variables.cpp
1// RUN: %clang_cc1 -std=c++17 -verify %s
2// expected-no-diagnostics
3template<bool> struct DominatorTreeBase {
4  static constexpr bool IsPostDominator = true;
5};
6extern template class DominatorTreeBase<false>;
7constexpr bool k = DominatorTreeBase<false>::IsPostDominator;
8
9namespace CompleteType {
10  template<unsigned N> constexpr int f(const bool (&)[N]) { return 0; }
11
12  template<bool ...V> struct X {
13    static constexpr bool arr[] = {V...};
14    static constexpr int value = f(arr);
15  };
16
17  constexpr int n = X<true>::value;
18}
19
20template <typename T> struct A {
21  static const int n;
22  static const int m;
23  constexpr int f() { return n; }
24  constexpr int g() { return n; }
25};
26template <typename T> constexpr int A<T>::n = sizeof(A) + sizeof(T);
27template <typename T> inline constexpr int A<T>::m = sizeof(A) + sizeof(T);
28static_assert(A<int>().f() == 5);
29static_assert(A<int>().g() == 5);
30