Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaTemplate / instantiate-var-template.cpp
blob60d3bd3b59f5333fc997a2a95c55636297358c63
1 // RUN: %clang_cc1 -verify -std=c++1y %s
3 namespace PR17846 {
4 template <typename T> constexpr T pi = T(3.14);
5 template <typename T> constexpr T tau = 2 * pi<T>;
6 constexpr double tau_double = tau<double>;
7 static_assert(tau_double == 6.28, "");
10 namespace PR17848 {
11 template<typename T> constexpr T var = 12345;
12 template<typename T> constexpr T f() { return var<T>; }
13 constexpr int k = f<int>();
14 static_assert(k == 12345, "");
17 namespace NonDependent {
18 template<typename T> constexpr T a = 0;
19 template<typename T> constexpr T b = a<int>;
20 static_assert(b<int> == 0, "");
23 namespace InstantiationDependent {
24 int f(int);
25 void f(char);
27 template<int> constexpr int a = 1;
28 template<typename T> constexpr T b = a<sizeof(sizeof(f(T())))>; // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}}
30 static_assert(b<int> == 1, "");
31 static_assert(b<char> == 1, ""); // expected-note {{in instantiation of}}
33 template<typename T> void f() {
34 int check[a<sizeof(sizeof(f(T())))> == 0 ? 1 : -1]; // expected-error {{array with a negative size}}
38 namespace PR24483 {
39 template<typename> struct A;
40 template<typename... T> A<T...> models;
41 template<> struct B models<>; // expected-error {{incomplete type 'struct B'}} expected-note {{forward declaration}}
44 namespace InvalidInsertPos {
45 template<typename T, int N> T v;
46 template<int N> decltype(v<int, N-1>) v<int, N>;
47 template<> int v<int, 0>;
48 int k = v<int, 500>;