diff options
Diffstat (limited to 'clang/test/CXX/temp')
| -rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp | 28 | ||||
| -rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp | 4 |
2 files changed, 30 insertions, 2 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp new file mode 100644 index 00000000000..b13ca937641 --- /dev/null +++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp @@ -0,0 +1,28 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// Test instantiation of static data members declared out-of-line. + +template<typename T> +struct X { + static T value; +}; + +template<typename T> + T X<T>::value = 17; // expected-error{{initialize}} + +struct InitOkay { + InitOkay(int) { } +}; + +struct CannotInit { }; + +int &returnInt() { return X<int>::value; } +float &returnFloat() { return X<float>::value; } + +InitOkay &returnInitOkay() { return X<InitOkay>::value; } + +unsigned long sizeOkay() { return sizeof(X<CannotInit>::value); } + +CannotInit &returnError() { + return X<CannotInit>::value; // expected-note{{instantiation}} +}
\ No newline at end of file diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp index 41d5f1baaed..37cae38cac6 100644 --- a/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp @@ -6,7 +6,7 @@ struct X0 { }; template<typename T> -T X0<T>::value = 0; +T X0<T>::value = 0; // expected-error{{initialize}} struct X1 { X1(int); @@ -20,7 +20,7 @@ X1& get_X1() { return X0<X1>::value; } double*& get_double_ptr() { return X0<int*>::value; } // expected-error{{initialized}} X2& get_X2() { - return X0<X2>::value; // FIXME: instantiation should fail! + return X0<X2>::value; // expected-note{{instantiation}} } template<typename T> T x; // expected-error{{variable 'x' declared as a template}}
\ No newline at end of file |

