Check that a partial specialization is more specialized.

* pt.c (process_partial_specialization): Use
	get_partial_spec_bindings to check that the partial specialization
	is more specialized than the primary template.

From-SVN: r243868
This commit is contained in:
Jason Merrill 2016-12-21 14:38:35 -05:00 committed by Jason Merrill
parent a93634ba09
commit a9410b4fe9
6 changed files with 21 additions and 6 deletions

View File

@ -1,5 +1,9 @@
2016-12-21 Jason Merrill <jason@redhat.com> 2016-12-21 Jason Merrill <jason@redhat.com>
* pt.c (process_partial_specialization): Use
get_partial_spec_bindings to check that the partial specialization
is more specialized than the primary template.
* pt.c (convert_template_argument): Pass args to do_auto_deduction. * pt.c (convert_template_argument): Pass args to do_auto_deduction.
(mark_template_parm): Handle deducibility from type of non-type (mark_template_parm): Handle deducibility from type of non-type
argument here. argument here.

View File

@ -4606,9 +4606,20 @@ process_partial_specialization (tree decl)
"primary template because it replaces multiple parameters " "primary template because it replaces multiple parameters "
"with a pack expansion"); "with a pack expansion");
inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here"); inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here");
/* Avoid crash in process_partial_specialization. */
return decl; return decl;
} }
/* If we aren't in a dependent class, we can actually try deduction. */
else if (tpd.level == 1
&& !get_partial_spec_bindings (maintmpl, maintmpl, specargs))
{
if (permerror (input_location, "partial specialization %qD is not "
"more specialized than", decl))
inform (DECL_SOURCE_LOCATION (maintmpl), "primary template %qD",
maintmpl);
}
/* [temp.class.spec] /* [temp.class.spec]
A partially specialized non-type argument expression shall not A partially specialized non-type argument expression shall not

View File

@ -12,7 +12,7 @@ template<typename _Tp, _Tp v>
}; };
// Partial specialization. // Partial specialization.
template<typename _Tp, _Tp v> template<typename _Tp, _Tp* v>
struct A3<_Tp*, v> struct A3<_Tp*, v>
{ {
typedef _Tp* value_type; typedef _Tp* value_type;

View File

@ -3,9 +3,9 @@
template<typename> struct A; template<typename> struct A;
template<typename... T> struct A<T*...> // { dg-bogus "cannot expand" "" } template<typename... T> struct A<T*...> // { dg-error "" }
{ {
struct B; struct B;
}; };
A<void*> a; // { dg-bogus "incomplete type" "" } A<void*> a;

View File

@ -3,6 +3,6 @@
template<typename> struct A; template<typename> struct A;
template<typename... T> struct A<T...> { }; // { dg-bogus "cannot expand" "" } template<typename... T> struct A<T...> { }; // { dg-error "" }
A<int> a; // { dg-bogus "incomplete type" "" } A<int> a;

View File

@ -14,7 +14,7 @@ template<typename T, typename T::foo V>
struct Y { }; struct Y { };
template<typename T, typename U, U v> template<typename T, typename U, U v>
struct Y<T, v> { }; // { dg-error "not deducible|U" "" { target { ! c++1z } } } struct Y<T, v> { }; // { dg-error "" }
template<typename T, T V> template<typename T, T V>