aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-12-21 14:38:44 -0500
committerJason Merrill <jason@gcc.gnu.org>2016-12-21 14:38:44 -0500
commit57a6add274e98def9fe937eea126c56a71e65c28 (patch)
tree5853c8fc2ab669e19226a16b1a0d5c25d65ee0c3
parenta9410b4fe946b3f82ff2254b46ef53573897d68e (diff)
downloadgcc-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
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic-ttp3.C23
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic-ttp3a.C20
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_tr1.h19
6 files changed, 60 insertions, 12 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);
+}
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 02297e0..6263652 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h
index c6a4986..908a788 100644
--- a/libstdc++-v3/testsuite/util/testsuite_tr1.h
+++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h
@@ -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,