/* C++ allows static class members. All other work
for this is done by grokfield. */
decl = build_lang_decl_loc (id_loc, VAR_DECL,
- unqualified_id, type);
+ dname, type);
+ if (unqualified_id
+ && TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR)
+ {
+ decl = check_explicit_specialization (unqualified_id, decl,
+ template_count,
+ concept_p * 8);
+ if (decl == error_mark_node)
+ return error_mark_node;
+ }
set_linkage_for_static_data_member (decl);
if (concept_p)
error_at (declspecs->locations[ds_concept],
return DECL_TI_TEMPLATE (decl);
}
else
- return decl;
+ return NULL_TREE;
}
else
error_at (DECL_SOURCE_LOCATION (decl),
--- /dev/null
+// PR c++/71954
+// { dg-do compile { target c++14 } }
+
+struct A {
+ template<class T> static const int var = 0;
+ template<class T> static const int var<T*> = 1;
+ template<class T> static const int var<const T*> = 2;
+};
+
+static_assert(A::var<int> == 0, "");
+static_assert(A::var<int*> == 1, "");
+static_assert(A::var<const int*> == 2, "");
--- /dev/null
+// PR c++/71954
+// A version of var-templ84.C where the partial specializations depend on
+// outer template parameters.
+// { dg-do compile { target c++14 } }
+
+template<class T>
+struct A {
+ template<class U, class V> static const int var = 0;
+ template<class U> static const int var<U*, T> = 1;
+ template<class U> static const int var<const U*, T> = 2;
+};
+
+static_assert(A<int>::var<int, int> == 0, "");
+static_assert(A<int>::var<int*, int> == 1, "");
+static_assert(A<int>::var<const int*, int> == 2, "");
+
+static_assert(A<int>::var<int, char> == 0, "");
+static_assert(A<int>::var<int*, char> == 0, "");
+static_assert(A<int>::var<const int*, char> == 0, "");