]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56794 (C++11 Error in range-based for with parameter pack array)
authorJason Merrill <jason@redhat.com>
Mon, 1 Apr 2013 21:19:03 +0000 (17:19 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 1 Apr 2013 21:19:03 +0000 (17:19 -0400)
PR c++/56794
* parser.c (cp_parser_range_for): Don't try to do auto deduction
in a template if the type of the range is incomplete.

From-SVN: r197328

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp0x/range-for24.C [new file with mode: 0644]

index 58c2b149c20e7494ba5a3fc812bce644208ddcda..bd0368b400d02af86c9d779cb3b7b5a67ce18c94 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56794
+       * parser.c (cp_parser_range_for): Don't try to do auto deduction
+       in a template if the type of the range is incomplete.
+
 2013-03-29  Jason Merrill  <jason@redhat.com>
 
        PR c++/56774
index f875b66ffa4a595f5c0ab1c2bfc60bc464a00577..f5c60d3c70e90c927146c7060e97c9f4b610c1e8 100644 (file)
@@ -9364,7 +9364,10 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
        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)
+      if (range_expr != error_mark_node
+         && !type_dependent_expression_p (range_expr)
+         /* The length of an array might be dependent.  */
+         && COMPLETE_TYPE_P (TREE_TYPE (range_expr))
          /* do_auto_deduction doesn't mess with template init-lists.  */
          && !BRACE_ENCLOSED_INITIALIZER_P (range_expr))
        do_range_for_auto_deduction (range_decl, range_expr);
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for24.C b/gcc/testsuite/g++.dg/cpp0x/range-for24.C
new file mode 100644 (file)
index 0000000..b4a5b18
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/56794
+// { dg-require-effective-target c++11 }
+
+template<int... values>
+static void Colors()
+{
+    static const int colors[] = { values... };
+
+    for(auto c: colors) { }
+}
+
+int main()
+{
+    Colors<0,1,2> ();
+}