]> granicus.if.org Git - clang/commitdiff
Add a constexpr functionality test for static data member templates.
authorLarisse Voufo <lvoufo@google.com>
Thu, 22 Aug 2013 01:05:27 +0000 (01:05 +0000)
committerLarisse Voufo <lvoufo@google.com>
Thu, 22 Aug 2013 01:05:27 +0000 (01:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188975 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/cxx1y-variable-templates_in_class.cpp

index c705354923550a96c9da4745344c8a6373dfd655..1505481912f93a140b53c1e3d8d20dc35299bb77 100644 (file)
@@ -124,6 +124,25 @@ namespace non_const_init {
   }
 }
 
+#ifndef PRECXX11
+namespace constexpred {
+  class A {
+    template<typename T> constexpr T wrong;           // expected-error {{member 'wrong' declared as a template}} \
+                                                      // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
+    template<typename T> constexpr T wrong_init = 5;      // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}}
+    template<typename T, typename T0> static constexpr T right = T(100);
+    template<typename T> static constexpr T right<T,int> = 5;
+    template<typename T> constexpr int right<int,T>;  // expected-error {{member 'right' declared as a template}} \
+                                                      // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
+    template<typename T> constexpr float right<float,T> = 5;  // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}}
+    template<> static constexpr int right<int,int> = 7;       // expected-error {{explicit specialization of 'right' in class scope}}
+    template<> static constexpr float right<float,int>;       // expected-error {{explicit specialization of 'right' in class scope}}
+    template static constexpr int right<int,int>;     // expected-error {{template specialization requires 'template<>'}} \
+                                                  // expected-error {{explicit specialization of 'right' in class scope}}
+  };
+}
+#endif
+
 struct matrix_constants {
   // TODO: (?)
 };