From 5bef11c8e7138b24f9f30bb778218d5151df65cb Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sun, 15 May 2011 23:04:04 +0000 Subject: [PATCH] re PR c++/48994 ([C++0x] error for trivial use of range-based 'for') PR c++/48994 * parser.c (cp_parser_perform_range_for_lookup): Call complete_type. From-SVN: r173778 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/range-for18.C | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/range-for18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f0371ad8b01..a425e758fc3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-05-15 Jonathan Wakely + + PR c++/48994 + * parser.c (cp_parser_perform_range_for_lookup): Call complete_type. + 2011-05-13 Ville Voutilainen Implement final on class. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a77d4ffb6ac..4e085abdf84 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8682,7 +8682,7 @@ cp_convert_range_for (tree statement, tree range_decl, tree range_expr) static tree cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end) { - if (!COMPLETE_TYPE_P (TREE_TYPE (range))) + if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (range)))) { error ("range-based % expression of type %qT " "has incomplete type", TREE_TYPE (range)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 94fa4742bb5..7065ec9a3ac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-15 Jonathan Wakely + + PR c++/48994 + * g++.dg/cpp0x/range-for18.C: New. + 2011-05-15 Tobias Burnus PR fortran/18918 diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for18.C b/gcc/testsuite/g++.dg/cpp0x/range-for18.C new file mode 100644 index 00000000000..386d73d1817 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for18.C @@ -0,0 +1,17 @@ +// PR c++/48994 + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template +struct myvec +{ + T* begin() const; + T* end() const; +}; + +void f(const myvec& v) +{ + for (int i : v) + ; +}