32 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5template<typename T>6struct X0 {7 static T value;8};9 10template<typename T>11T X0<T>::value = 0; // expected-error{{no viable conversion}}12 13struct X1 {14 X1(int);15};16 17struct X2 { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}18#if __cplusplus >= 201103L // C++11 or later19// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}20#endif21 22int& get_int() { return X0<int>::value; }23X1& get_X1() { return X0<X1>::value; }24 25double*& get_double_ptr() { return X0<int*>::value; } // expected-error{{non-const lvalue reference to type 'double *' cannot bind to a value of unrelated type 'int *'}}26 27X2& get_X2() {28 return X0<X2>::value; // expected-note{{instantiation}}29}30 31template<typename T> T x; // expected-warning 0-1{{variable templates are a C++14 extension}}32