diff options
author | Jason Merrill <jason@redhat.com> | 2016-12-21 14:38:44 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-12-21 14:38:44 -0500 |
commit | 57a6add274e98def9fe937eea126c56a71e65c28 (patch) | |
tree | 5853c8fc2ab669e19226a16b1a0d5c25d65ee0c3 /gcc | |
parent | a9410b4fe946b3f82ff2254b46ef53573897d68e (diff) | |
download | gcc-57a6add274e98def9fe937eea126c56a71e65c28.zip gcc-57a6add274e98def9fe937eea126c56a71e65c28.tar.gz gcc-57a6add274e98def9fe937eea126c56a71e65c28.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic-ttp3.C | 23 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic-ttp3a.C | 20 |
4 files changed, 47 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7faac15..05d6dba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8abbcfb..f839c53 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3.C new file mode 100644 index 0000000..b1bd7a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3.C @@ -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" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3a.C new file mode 100644 index 0000000..b3599b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp3a.C @@ -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); +} |