TemplateParams->getRAngleLoc());
TemplateParams = 0;
} else {
- // Only C++1y supports variable templates (N3651).
- Diag(D.getIdentifierLoc(),
- getLangOpts().CPlusPlus1y
- ? diag::warn_cxx11_compat_variable_template
- : diag::ext_variable_template);
-
if (D.getName().getKind() == UnqualifiedId::IK_TemplateId) {
// This is an explicit specialization or a partial specialization.
// FIXME: Check that we can declare a specialization here.
// Check that we can declare a template here.
if (CheckTemplateDeclScope(S, TemplateParams))
return 0;
+
+ // Only C++1y supports variable templates (N3651).
+ Diag(D.getIdentifierLoc(),
+ getLangOpts().CPlusPlus1y
+ ? diag::warn_cxx11_compat_variable_template
+ : diag::ext_variable_template);
}
}
}
template<> void ft<int>() {}
template void ft<char>(); // expected-error {{undefined}}
- template<typename T> int mt<T*>; // expected-warning {{extension}}
- template<> int mt<int>; // expected-warning {{extension}}
+ template<typename T> int mt<T*>;
+ template<> int mt<int>;
template int mt<int*>;
template int mt<char>; // expected-error {{undefined}}
template<> void N::gt<int>() {}
template void N::gt<char>(); // expected-error {{undefined}}
- template<typename T> int N::nt<T*>; // expected-warning {{extension}}
- template<> int N::nt<int>; // expected-warning {{extension}}
+ template<typename T> int N::nt<T*>;
+ template<> int N::nt<int>;
template int N::nt<int*>;
template int N::nt<char>; // expected-error {{undefined}}
// expected-warning@-4 {{variable templates are a C++1y extension}}
#endif
+// No diagnostic for specializations of variable templates; we will have
+// diagnosed the primary template.
template<typename T> T* var<T*> = new T();
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
-#else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
-#endif
-
template<> int var<int> = 10;
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
-#else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
-#endif
-
template int var<int>;
float fvar = var<float>;
-class A {
+class A {
template<typename T> static T var = T(10);
#ifdef CXX1YCOMPAT
// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
#else
// expected-warning@-4 {{variable templates are a C++1y extension}}
-#endif
-
- template<typename T> static T* var<T*> = new T();
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
-#else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
#endif
+ template<typename T> static T* var<T*> = new T();
};
struct B { template<typename T> static T v; };
#endif
template<typename T> T* B::v<T*> = new T();
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
-#else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
-#endif
-
template<> int B::v<int> = 10;
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
-#else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
-#endif
-
template int B::v<int>;
float fsvar = B::v<float>;