Fix handling of explicit function template arguments with TTPs.
gcc/cp/ * pt.c (coerce_template_parms): Consider variadic_args_p before complaining about too many template arguments. libstdc++-v3/ * testsuite/util/testsuite_tr1.h (test_property): Don't define both variadic and non-variadic overloads. From-SVN: r243869
This commit is contained in:
parent
a9410b4fe9
commit
57a6add274
|
@ -1,5 +1,8 @@
|
|||
2016-12-21 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* pt.c (coerce_template_parms): Consider variadic_args_p before
|
||||
complaining about too many template arguments.
|
||||
|
||||
* pt.c (process_partial_specialization): Use
|
||||
get_partial_spec_bindings to check that the partial specialization
|
||||
is more specialized than the primary template.
|
||||
|
|
|
@ -7658,7 +7658,7 @@ coerce_template_parms (tree parms,
|
|||
variadic_args_p = pack_expansion_args_count (inner_args);
|
||||
|
||||
nargs = inner_args ? NUM_TMPL_ARGS (inner_args) : 0;
|
||||
if ((nargs > nparms && !variadic_p)
|
||||
if ((nargs - variadic_args_p > nparms && !variadic_p)
|
||||
|| (nargs < nparms - variadic_p
|
||||
&& require_all_args
|
||||
&& !variadic_args_p
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// Test that passing a non-variadic template to a variadic TTP works
|
||||
// with explicit template arguments in a function call..
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
template<template<typename> class Property, typename Type>
|
||||
bool test_property(typename Property<Type>::value_type value);
|
||||
|
||||
template<template<typename...> class Property,
|
||||
typename Type1, typename... Types>
|
||||
bool test_property(typename Property<Type1, Types...>::value_type value);
|
||||
|
||||
template <class T>
|
||||
struct X
|
||||
{
|
||||
using type = X;
|
||||
using value_type = int;
|
||||
static const value_type value = 42;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_property<X,int>(42); // { dg-error "ambiguous" }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// Test that passing a non-variadic template to a variadic TTP works
|
||||
// with explicit template arguments in a function call..
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
template<template<typename...> class Property,
|
||||
typename Type1, typename... Types>
|
||||
bool test_property(typename Property<Type1, Types...>::value_type value);
|
||||
|
||||
template <class T>
|
||||
struct X
|
||||
{
|
||||
using type = X;
|
||||
using value_type = int;
|
||||
static const value_type value = 42;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_property<X,int>(42);
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
2016-12-16 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* testsuite/util/testsuite_tr1.h (test_property): Don't define both
|
||||
variadic and non-variadic overloads.
|
||||
|
||||
2016-12-21 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/71444
|
||||
|
|
|
@ -45,17 +45,6 @@ namespace __gnu_test
|
|||
&& Category<const volatile Type>::type::value == value);
|
||||
}
|
||||
|
||||
template<template<typename> class Property, typename Type>
|
||||
#if __cplusplus >= 201103L
|
||||
constexpr
|
||||
#endif
|
||||
bool
|
||||
test_property(typename Property<Type>::value_type value)
|
||||
{
|
||||
return (Property<Type>::value == value
|
||||
&& Property<Type>::type::value == value);
|
||||
}
|
||||
|
||||
// For testing tr1/type_traits/extent, which has a second template
|
||||
// parameter.
|
||||
template<template<typename, unsigned> class Property,
|
||||
|
@ -79,6 +68,14 @@ namespace __gnu_test
|
|||
return (Property<Type1, Types...>::value == value
|
||||
&& Property<Type1, Types...>::type::value == value);
|
||||
}
|
||||
#else
|
||||
template<template<typename> class Property, typename Type>
|
||||
bool
|
||||
test_property(typename Property<Type>::value_type value)
|
||||
{
|
||||
return (Property<Type>::value == value
|
||||
&& Property<Type>::type::value == value);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<template<typename, typename> class Relationship,
|
||||
|
|
Loading…
Reference in New Issue