re PR c++/48994 ([C++0x] error for trivial use of range-based 'for')
authorJonathan Wakely <jwakely.gcc@gmail.com>
Sun, 15 May 2011 23:04:04 +0000 (23:04 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Sun, 15 May 2011 23:04:04 +0000 (00:04 +0100)
PR c++/48994
* parser.c (cp_parser_perform_range_for_lookup): Call complete_type.

From-SVN: r173778

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

index f0371ad8b0164459494d3e942fe979dbe35c7f14..a425e758fc31a5e736d98f1e6a8420c60f5f12aa 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-15  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR c++/48994
+       * parser.c (cp_parser_perform_range_for_lookup): Call complete_type.
+
 2011-05-13  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Implement final on class.
index a77d4ffb6ac4508b1e2556964e129f5de2a5ad56..4e085abdf84ea622f356c459ffa555a1e6534cc0 100644 (file)
@@ -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 %<for%> expression of type %qT "
             "has incomplete type", TREE_TYPE (range));
index 94fa4742bb55a99725f8d49184e59c34bcd324d3..7065ec9a3ac110b18e02cdd1bc23190bb0803c2c 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-15  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR c++/48994
+       * g++.dg/cpp0x/range-for18.C: New.
+
 2011-05-15  Tobias Burnus  <burnus@net-b.de>
 
        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 (file)
index 0000000..386d73d
--- /dev/null
@@ -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)
+        ;
+}