From fcbc2bedbfb3a584bd98a7792d7d088db8e8c6fd Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 5 Aug 2011 15:12:16 -0400 Subject: [PATCH] re PR c++/49983 ([C++0x] Template types fail in range-based for.) 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 | 4 ++++ gcc/cp/parser.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/range-for21.C | 8 ++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/range-for21.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8eb6b74c3ce..d7ad9929c93 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-08-05 Jason Merrill + 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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9b3e56d07f4..84b8c608f95 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24e145c09e9..4956e57e777 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-05 Jason Merrill + PR c++/49983 + * g++.dg/cpp0x/range-for21.C: New. + * g++.dg/ext/vla11.C: New. 2011-08-05 Richard Guenther diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for21.C b/gcc/testsuite/g++.dg/cpp0x/range-for21.C new file mode 100644 index 00000000000..07bb95fbf2b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for21.C @@ -0,0 +1,8 @@ +// PR c++/49983 +// { dg-options -std=c++0x } + +template +void f(T t) +{ + for (auto v : t); +} -- 2.30.2