for (t = DECL_TEMPLATE_SPECIALIZATIONS (main_tmpl); t; t = TREE_CHAIN (t))
{
- tree spec_args;
- tree spec_tmpl = TREE_VALUE (t);
+ const tree ospec_tmpl = TREE_VALUE (t);
+ tree spec_tmpl;
if (outer_args)
{
/* Substitute in the template args from the enclosing class. */
++processing_template_decl;
- spec_tmpl = tsubst (spec_tmpl, outer_args, tf_none, NULL_TREE);
+ spec_tmpl = tsubst (ospec_tmpl, outer_args, tf_none, NULL_TREE);
--processing_template_decl;
+ if (spec_tmpl == error_mark_node)
+ return error_mark_node;
}
+ else
+ spec_tmpl = ospec_tmpl;
- if (spec_tmpl == error_mark_node)
- return error_mark_node;
-
- spec_args = get_partial_spec_bindings (tmpl, spec_tmpl, args);
+ tree spec_args = get_partial_spec_bindings (tmpl, spec_tmpl, args);
if (spec_args)
{
if (outer_args)
/* Keep the candidate only if the constraints are satisfied,
or if we're not compiling with concepts. */
if (!flag_concepts
- || constraints_satisfied_p (spec_tmpl, spec_args))
+ || constraints_satisfied_p (ospec_tmpl, spec_args))
{
- list = tree_cons (spec_args, TREE_VALUE (t), list);
+ list = tree_cons (spec_args, ospec_tmpl, list);
TREE_TYPE (list) = TREE_TYPE (t);
}
}
--- /dev/null
+// PR c++/92103
+// { dg-do compile { target c++20 } }
+
+template<int M>
+struct traits
+{
+ template<int N>
+ struct equal_to
+ { static constexpr bool value = false; };
+
+ template<int N> requires (M == N)
+ struct equal_to<N>
+ { static constexpr bool value = true; };
+
+ template<int N> requires (M < 0) || (N < 0)
+ struct equal_to<N>
+ { };
+};
+
+static_assert(traits<0>::equal_to<0>::value);
+static_assert(!traits<0>::equal_to<1>::value);
+static_assert(traits<-1>::equal_to<0>::value); // { dg-error "not a member" }