diff mbox

fix c++/48994

Message ID BANLkTim5nMSRJddwRzU6y69-LZ9pdCbQxw@mail.gmail.com
State New
Headers show

Commit Message

Jonathan Wakely May 15, 2011, 10:02 a.m. UTC
cp/ChangeLog

        PR c++/48994
        * parser.c (cp_parser_perform_range_for_lookup): Call complete_type.

testsuite/ChangeLog

        PR c++/48994
        * g++.dg/cpp0x/range-for18.C: New.

Tested x86_64-linux, ok for trunk?

Comments

Jason Merrill May 15, 2011, 10:19 p.m. UTC | #1
OK for trunk and 4.6.

Jason
Jonathan Wakely May 15, 2011, 11:07 p.m. UTC | #2
On 15 May 2011 23:19, Jason Merrill wrote:
> OK for trunk and 4.6.

The bug isn't present on the 4.6 branch and I'm not sure where the
change should go, if it's needed at all, so I've only committed it to
trunk.
Jason Merrill May 16, 2011, 2:16 a.m. UTC | #3
On 05/15/2011 07:07 PM, Jonathan Wakely wrote:
> On 15 May 2011 23:19, Jason Merrill wrote:
>> OK for trunk and 4.6.
>
> The bug isn't present on the 4.6 branch and I'm not sure where the
> change should go, if it's needed at all, so I've only committed it to
> trunk.

Ah, my mistake.  Sounds good.

Jason
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 173683)
+++ cp/parser.c	(working copy)
@@ -8682,7 +8682,7 @@ 
 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 %<for%> expression of type %qT "
 	     "has incomplete type", TREE_TYPE (range));
Index: testsuite/g++.dg/cpp0x/range-for18.C
===================================================================
--- testsuite/g++.dg/cpp0x/range-for18.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/range-for18.C	(revision 0)
@@ -0,0 +1,17 @@ 
+// PR c++/48994
+
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template <typename T>
+struct myvec
+{
+    T* begin() const;
+    T* end() const;
+};
+
+void f(const myvec<int>& v)
+{
+    for (int i : v)
+        ;
+}