re PR c++/57243 (Using auto in range based for with templated container in templated...
authorJason Merrill <jason@redhat.com>
Tue, 14 May 2013 20:36:32 +0000 (16:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 14 May 2013 20:36:32 +0000 (16:36 -0400)
PR c++/57243
* parser.c (cp_parser_range_for): Call complete_type.

From-SVN: r198901

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

index 1dae892..aea304b 100644 (file)
@@ -1,5 +1,8 @@
 2013-05-14  Jason Merrill  <jason@redhat.com>
 
+       PR c++/57243
+       * parser.c (cp_parser_range_for): Call complete_type.
+
        PR c++/57041
        * pt.c (tsubst_copy_and_build): Don't recur into a designator.
 
index f65ec97..0a075b2 100644 (file)
@@ -9735,7 +9735,7 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
       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))
+         && COMPLETE_TYPE_P (complete_type (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-for25.C b/gcc/testsuite/g++.dg/cpp0x/range-for25.C
new file mode 100644 (file)
index 0000000..8ba9f65
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/57243
+// { dg-require-effective-target c++11 }
+
+struct snarf
+{
+  template <class T>
+  void get() {}
+};
+
+template <class T>
+struct container
+{
+  snarf * begin() { return nullptr; }
+  snarf * end() { return nullptr; }
+};
+
+template <class T>
+void foo()
+{
+  container<int> arr;
+
+  for( auto i : arr )
+    i.get<int>();
+}
+
+int main()
+{
+  return 0;
+}
+