24 lines · cpp
1// RUN: %clang_cc1 -std=c++98 -verify=cxx98 %s2// RUN: %clang_cc1 -std=c++11 -verify=cxx11 %s3// cxx11-no-diagnostics4 5template<int n> struct S;6 7template<int n> struct T {8 T() {9 // An identifier is value-dependent if it is:10 // - a name declared with a dependent type11 S<n> s;12 S<s> check1; // ok, s is value-dependent13 // - the name of a non-type template parameter14 typename S<n>::T check2; // ok, n is value-dependent15 // - a constant with literal type and is initialized with an expression16 // that is value-dependent.17 const int k = n;18 typename S<k>::T check3; // ok, k is value-dependent19 20 const int &i = k; // cxx98-note {{declared here}}21 typename S<i>::T check4; // cxx98-error {{not an integral constant expression}} cxx98-note {{read of variable 'i' of non-integral, non-enumeration type 'const int &'}}22 }23};24