diff mbox

C++ PATCH for c++/51046 (ICE with unexpanded parameter pack)

Message ID 4EBAFCDD.90604@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 9, 2011, 10:21 p.m. UTC
Missing a call to check_for_bare_parameter_packs.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 3d2892d25a37984099611c02614fc9788e14d4c4
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 9 14:25:21 2011 -0500

    	PR c++/51046
    	* parser.c (cp_parser_range_for): check_for_bare_parameter_packs.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3cb6dbf..fc8f3c8 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9292,6 +9292,8 @@  cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
      at instantiation. If not, it is done just ahead. */
   if (processing_template_decl)
     {
+      if (check_for_bare_parameter_packs (range_expr))
+	range_expr = error_mark_node;
       stmt = begin_range_for_stmt (scope, init);
       finish_range_for_decl (stmt, range_decl, range_expr);
       if (!type_dependent_expression_p (range_expr)
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic119.C b/gcc/testsuite/g++.dg/cpp0x/variadic119.C
new file mode 100644
index 0000000..78cd23e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic119.C
@@ -0,0 +1,13 @@ 
+// PR c++/51046
+// { dg-do compile { target c++11 } }
+
+template<int... IS>
+void f()
+{
+  for (int i : IS);		// { dg-error "not expanded" }
+}
+
+int main()
+{
+  f<0, 1, 2>();
+}