1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -std=c++1y %s 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc namespace PR17846 { 4*0a6a1f1dSLionel Sambuc template <typename T> constexpr T pi = T(3.14); 5*0a6a1f1dSLionel Sambuc template <typename T> constexpr T tau = 2 * pi<T>; 6*0a6a1f1dSLionel Sambuc constexpr double tau_double = tau<double>; 7*0a6a1f1dSLionel Sambuc static_assert(tau_double == 6.28, ""); 8*0a6a1f1dSLionel Sambuc } 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc namespace PR17848 { 11*0a6a1f1dSLionel Sambuc template<typename T> constexpr T var = 12345; f()12*0a6a1f1dSLionel Sambuc template<typename T> constexpr T f() { return var<T>; } 13*0a6a1f1dSLionel Sambuc constexpr int k = f<int>(); 14*0a6a1f1dSLionel Sambuc static_assert(k == 12345, ""); 15*0a6a1f1dSLionel Sambuc } 16*0a6a1f1dSLionel Sambuc 17*0a6a1f1dSLionel Sambuc namespace NonDependent { 18*0a6a1f1dSLionel Sambuc template<typename T> constexpr T a = 0; 19*0a6a1f1dSLionel Sambuc template<typename T> constexpr T b = a<int>; 20*0a6a1f1dSLionel Sambuc static_assert(b<int> == 0, ""); 21*0a6a1f1dSLionel Sambuc } 22*0a6a1f1dSLionel Sambuc 23*0a6a1f1dSLionel Sambuc namespace InstantiationDependent { 24*0a6a1f1dSLionel Sambuc int f(int); 25*0a6a1f1dSLionel Sambuc void f(char); 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc template<int> constexpr int a = 1; 28*0a6a1f1dSLionel Sambuc template<typename T> constexpr T b = a<sizeof(sizeof(f(T())))>; // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuc static_assert(b<int> == 1, ""); 31*0a6a1f1dSLionel Sambuc static_assert(b<char> == 1, ""); // expected-note {{in instantiation of}} expected-error {{not an integral constant}} 32*0a6a1f1dSLionel Sambuc f()33*0a6a1f1dSLionel Sambuc template<typename T> void f() { 34*0a6a1f1dSLionel Sambuc static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // expected-error {{static_assert failed}} 35*0a6a1f1dSLionel Sambuc } 36*0a6a1f1dSLionel Sambuc } 37