From ef1a09a3368c4ac421c00d14923cd31902ba9dfb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 25 Mar 2009 23:32:15 +0000 Subject: Implement template instantiation for static data members of class templates, including in-class initializers. For example: template class X { public: static const T value = 10 / Divisor; }; instantiated with, e.g., X::value to get the value '2'. llvm-svn: 67715 --- clang/test/SemaTemplate/instantiate-static-var.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 clang/test/SemaTemplate/instantiate-static-var.cpp (limited to 'clang/test/SemaTemplate/instantiate-static-var.cpp') diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp new file mode 100644 index 00000000000..99e6b9cc06c --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-static-var.cpp @@ -0,0 +1,18 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template +class X { +public: + static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}} +}; + +int array1[X::value == 5? 1 : -1]; +X xi0; // expected-note{{in instantiation of template class 'class X' requested here}} + + +template +class Y { + static const T value = 0; // expected-error{{'value' can only be initialized if it is a static const integral data member}} +}; + +Y fy; // expected-note{{in instantiation of template class 'class Y' requested here}} -- cgit v1.2.3