| 1 |
// RUN: %clang_cc1 -std=c++17 -verify %s |
| 2 |
|
| 3 |
template<bool> struct DominatorTreeBase { |
| 4 |
static constexpr bool IsPostDominator = true; |
| 5 |
}; |
| 6 |
extern template class DominatorTreeBase<false>; |
| 7 |
constexpr bool k = DominatorTreeBase<false>::IsPostDominator; |
| 8 |
|
| 9 |
namespace 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 |
|
| 20 |
template <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 |
}; |
| 26 |
template <typename T> constexpr int A<T>::n = sizeof(A) + sizeof(T); |
| 27 |
template <typename T> inline constexpr int A<T>::m = sizeof(A) + sizeof(T); |
| 28 |
static_assert(A<int>().f() == 5); |
| 29 |
static_assert(A<int>().g() == 5); |
| 30 |
|
| 31 |
namespace GH135032 { |
| 32 |
|
| 33 |
template <typename T> struct InlineAuto { |
| 34 |
template <typename G> inline static auto var = 5; |
| 35 |
}; |
| 36 |
|
| 37 |
template <typename> struct PartialInlineAuto { |
| 38 |
template <typename, typename> inline static auto var = 6; |
| 39 |
template <typename T> inline static auto var<int, T> = 7; |
| 40 |
}; |
| 41 |
|
| 42 |
int inline_auto = InlineAuto<int>::var<int>; |
| 43 |
int partial_inline_auto = PartialInlineAuto<int>::var<int, int>; |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
namespace GH140773 { |
| 48 |
template <class T> class ConstString { // #ConstString |
| 49 |
ConstString(typename T::type) {} // #ConstString-Ctor |
| 50 |
}; |
| 51 |
|
| 52 |
template <class = int> |
| 53 |
struct Foo { |
| 54 |
template <char> |
| 55 |
static constexpr ConstString kFilename{[] { // #kFileName |
| 56 |
return 42; |
| 57 |
}}; |
| 58 |
}; |
| 59 |
|
| 60 |
// We don't want to instantiate the member template until it's used! |
| 61 |
Foo<> foo; |
| 62 |
|
| 63 |
auto X = Foo<>::kFilename<'a'>; |
| 64 |
// expected-error@#kFileName {{no viable constructor}} |
| 65 |
// expected-note@-2 {{in instantiation of static data member}} |
| 66 |
// expected-note@#ConstString-Ctor {{candidate template ignored}} |
| 67 |
// expected-note@#ConstString-Ctor {{implicit deduction guide}} |
| 68 |
// expected-note@#ConstString {{candidate template ignored}} |
| 69 |
// expected-note@#ConstString {{implicit deduction guide}} |
| 70 |
|
| 71 |
} |