Home | History | Annotate | Download | only in SemaTemplate
      1 // RUN: %clang_cc1 -verify -std=c++1y %s
      2 
      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, "");
      8 }
      9 
     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, "");
     15 }
     16 
     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, "");
     21 }
     22 
     23 namespace InstantiationDependent {
     24   int f(int);
     25   void f(char);
     26 
     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'}}
     29 
     30   static_assert(b<int> == 1, "");
     31   static_assert(b<char> == 1, ""); // expected-note {{in instantiation of}} expected-error {{not an integral constant}}
     32 
     33   template<typename T> void f() {
     34     static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // expected-error {{static_assert failed}}
     35   }
     36 }
     37 
     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}}
     42 }
     43