public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/50020 (ICE with auto range for in template member function)
@ 2011-08-08 15:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-08-08 15:43 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

The update to range-for lookup of 'begin' and 'end' added support for 
COMPONENT_REF to finish_call_expr; we need to check for it here, too.

Tested x86_64-pc-linux-gnu, applied to trunk.

[-- Attachment #2: 50020.patch --]
[-- Type: text/x-patch, Size: 2062 bytes --]

commit 5509a56f6699e727a27a8010a566027cb41191f7
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Aug 8 10:56:49 2011 -0400

    	PR c++/50020
    	* semantics.c (finish_call_expr): Don't look at 'this' if we
    	had an explicit object argument.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index aa62049..59b25e5 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2042,12 +2042,14 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
 	 expressions with no type as being dependent.  */
       if (type_dependent_expression_p (fn)
 	  || any_type_dependent_arguments_p (*args)
-	  /* For a non-static member function, we need to specifically
+	  /* For a non-static member function that doesn't have an
+	     explicit object argument, we need to specifically
 	     test the type dependency of the "this" pointer because it
 	     is not included in *ARGS even though it is considered to
 	     be part of the list of arguments.  Note that this is
 	     related to CWG issues 515 and 1005.  */
-	  || (non_static_member_function_p (fn)
+	  || (TREE_CODE (fn) != COMPONENT_REF
+	      && non_static_member_function_p (fn)
 	      && current_class_ref
 	      && type_dependent_expression_p (current_class_ref)))
 	{
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for20.C b/gcc/testsuite/g++.dg/cpp0x/range-for20.C
index 8205b22..890eb0a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/range-for20.C
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for20.C
@@ -1,4 +1,5 @@
 // PR c++/49834
+// PR c++/50020
 // { dg-options -std=c++0x }
 
 struct A
@@ -17,16 +18,19 @@ struct C
 };
 
 template <typename Ret>
-Ret f(const C &p)
+struct D
 {
-  for (const B &i: p)		// OK
-    i.second.get_value<int>();
-  for (const auto &i: p)	// ERROR
-    i.second.get_value<int>();
-  return Ret(0);
-}
+  Ret f(const C &p)
+  {
+    for (const B &i: p)		// OK
+      i.second.get_value<int>();
+    for (const auto &i: p)	// ERROR
+      i.second.get_value<int>();
+    return Ret(0);
+  }
+};
 
 void g()
 {
-  f<int>(C());
+  D<int>().f(C());
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-08 15:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-08 15:43 C++ PATCH for c++/50020 (ICE with auto range for in template member function) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).