diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-07-24 20:34:43 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-07-24 20:34:43 +0000 |
| commit | a6ef8f0813d55266dea52b49f13d0a250b5dad7d (patch) | |
| tree | 75223c997ff48ecf222d37857c327b415e243a2f /clang/test | |
| parent | 4dcc53f3125d7af704a47df97fb38a6d930bb5c4 (diff) | |
| download | bcm5719-llvm-a6ef8f0813d55266dea52b49f13d0a250b5dad7d.tar.gz bcm5719-llvm-a6ef8f0813d55266dea52b49f13d0a250b5dad7d.zip | |
Template instantiation for static data members that are defined out-of-line.
Note that this also fixes a bug that affects non-template code, where we
were not treating out-of-line static data members are "file-scope" variables,
and therefore not checking their initializers.
llvm-svn: 77002
Diffstat (limited to 'clang/test')
| -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 |

