aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-11-13 01:52:43 -0500
committerJason Merrill <jason@gcc.gnu.org>2016-11-13 01:52:43 -0500
commit559f2bbc362f311ab424232e72bb4f9f601b54eb (patch)
tree56a3e898f32738bfb23ec8dbec54270080af2307 /gcc
parentdc8d2d00c52e29a4d68576cecdcc161484123195 (diff)
downloadgcc-559f2bbc362f311ab424232e72bb4f9f601b54eb.zip
gcc-559f2bbc362f311ab424232e72bb4f9f601b54eb.tar.gz
gcc-559f2bbc362f311ab424232e72bb4f9f601b54eb.tar.bz2
CWG 2233 - default arg and parameter pack
* typeck.c (convert_arguments): Handle default arg followed by none. From-SVN: r242350
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/typeck.c9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic169.C9
3 files changed, 19 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b2195e4..8683744 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2016-11-12 Jason Merrill <jason@redhat.com>
+ CWG 2233
+ * typeck.c (convert_arguments): Handle default arg followed by none.
+
* constexpr.c (potential_constant_expression_1): REALPART_EXPR and
IMAGPART_EXPR can be lvalues.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 211696c..24ca1b5 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3835,6 +3835,10 @@ convert_arguments (tree typelist, vec<tree, va_gc> **values, tree fndecl,
{
for (; typetail != void_list_node; ++i)
{
+ /* After DR777, with explicit template args we can end up with a
+ default argument followed by no default argument. */
+ if (!TREE_PURPOSE (typetail))
+ break;
tree parmval
= convert_default_arg (TREE_VALUE (typetail),
TREE_PURPOSE (typetail),
@@ -3850,9 +3854,10 @@ convert_arguments (tree typelist, vec<tree, va_gc> **values, tree fndecl,
break;
}
}
- else
+
+ if (typetail && typetail != void_list_node)
{
- if (complain & tf_error)
+ if (complain & tf_error)
error_args_num (input_location, fndecl, /*too_many_p=*/false);
return -1;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic169.C b/gcc/testsuite/g++.dg/cpp0x/variadic169.C
new file mode 100644
index 0000000..6858973
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic169.C
@@ -0,0 +1,9 @@
+// DR 2233
+// { dg-do compile { target c++11 } }
+
+template<typename ...T> void f(int n = 0, T ...t);
+
+int main()
+{
+ f<int>(); // { dg-error "too few arguments" }
+}