re PR c++/49983 ([C++0x] Template types fail in range-based for.)
authorJason Merrill <jason@redhat.com>
Fri, 5 Aug 2011 19:12:16 +0000 (15:12 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 5 Aug 2011 19:12:16 +0000 (15:12 -0400)
PR c++/49983
* parser.c (cp_parser_range_for): Only do auto deduction in
template if the range is non-dependent.

From-SVN: r177478

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

index 8eb6b74c3ce0ed51cf773c2e54988462cef61630..d7ad9929c931a048f71a6eea7ab4b5fc4282d4f1 100644 (file)
@@ -1,5 +1,9 @@
 2011-08-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49983
+       * parser.c (cp_parser_range_for): Only do auto deduction in
+       template if the range is non-dependent.
+
        * init.c (perform_member_init): Always build_aggr_init
        for a class member with an explicit mem-initializer.
 
index 9b3e56d07f43d2abd1f61c50cf6b88878f706473..84b8c608f9552254c7cc0d81f7f6bcffee73008c 100644 (file)
@@ -8679,7 +8679,8 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl)
     {
       stmt = begin_range_for_stmt (scope, init);
       finish_range_for_decl (stmt, range_decl, range_expr);
-      do_range_for_auto_deduction (range_decl, range_expr);
+      if (!type_dependent_expression_p (range_expr))
+       do_range_for_auto_deduction (range_decl, range_expr);
     }
   else
     {
index 24e145c09e97584a4c16bd0554f225633d8c664c..4956e57e77737fa84b80caa21e591c2012674858 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49983
+       * g++.dg/cpp0x/range-for21.C: New.
+
        * g++.dg/ext/vla11.C: New.
 
 2011-08-05  Richard Guenther  <rguenther@suse.de>
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for21.C b/gcc/testsuite/g++.dg/cpp0x/range-for21.C
new file mode 100644 (file)
index 0000000..07bb95f
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/49983
+// { dg-options -std=c++0x }
+
+template <class T>
+void f(T t)
+{
+  for (auto v : t);
+}