brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · a63ffa9 Raw
43 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -verify %s -fexperimental-new-constant-interpreter2 3template<int n> struct S; // expected-note 3{{here}}4 5struct LiteralType {6  constexpr LiteralType(int n) : n(n) {}7  int n;8};9 10template<int n> struct T {11  T() {12    // An identifier is value-dependent if it is:13    //  - a name declared with a dependent type14    S<n> s;15    S<s> check1; // ok, s is value-dependent16    //  - the name of a non-type template parameter17    typename S<n>::T check2; // ok, n is value-dependent18    //  - a potentially-constant variable that is initialized with an19    //    expression that is value-dependent.20    const int k = n;21    typename S<k>::T check3a; // ok, u is value-dependent22 23    constexpr const int *p = &k;24    typename S<*p>::T check3b; // ok, p is value-dependent25 26    const int &i = k;27    typename S<i>::T check4; // ok, i is value-dependent28 29    static const int ki = 42;30    const int &i2 = ki;31    typename S<i2>::T check5; // expected-error {{undefined template}}32 33    constexpr LiteralType x = n;34    typename S<true ? 1 : x.n>::T check6; // ok, x is value-dependent35 36    const LiteralType y = n;37    typename S<true ? 2 : y.n>::T check7; // expected-error {{undefined template}}38 39    constexpr LiteralType z = 42;40    typename S<true ? 3 : z.n>::T check8; // expected-error {{undefined template}}41  }42};43