OSDN Git Service

PR c++/49983
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Aug 2011 19:12:16 +0000 (19:12 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Aug 2011 19:12:16 +0000 (19:12 +0000)
* parser.c (cp_parser_range_for): Only do auto deduction in
template if the range is non-dependent.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177478 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8eb6b74..d7ad992 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 9b3e56d..84b8c60 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 24e145c..4956e57 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);
+}