diff mbox

[C++] PR 57543

Message ID 5384935D.5020406@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 27, 2014, 1:30 p.m. UTC
Hi,

here, in order to accept the code without an explicit this-> 
qualification, I propose to simply notice that instance == 
current_class_type. Tested x86_64-linux.

Thanks!
Paolo.

////////////////////
/cp
2014-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57543
	* call.c (build_new_method_call_1): In an unevaluated context
	allow calling a member function of the same class.

/testsuite
2014-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57543
	* g++.dg/cpp0x/decltype59.C: New.

Comments

Jason Merrill May 27, 2014, 5:15 p.m. UTC | #1
I don't think this is the right place for the fix; why do we have a 
dummy object at all?  Doesn't maybe_dummy_object return 
current_class_ref in this situation?

Jason
diff mbox

Patch

Index: cp/call.c
===================================================================
--- cp/call.c	(revision 210956)
+++ cp/call.c	(working copy)
@@ -8000,6 +8000,20 @@  build_new_method_call_1 (tree instance, tree fns,
 		     we know we really need it.  */
 		  cand->first_arg = instance;
 		}
+	      else if (cp_unevaluated_operand != 0
+		       && current_class_type
+		       && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (instance)),
+				       current_class_type))
+		{
+		  /* For example (c++/57543):
+
+		     template< typename > struct X
+		     {
+		       void foo();
+		       auto bar() -> decltype( X::foo() );
+		     };  */
+		  gcc_assert (cand->first_arg == instance);
+		}
 	      else
 		{
 		  if (complain & tf_error)
Index: testsuite/g++.dg/cpp0x/decltype59.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype59.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/decltype59.C	(working copy)
@@ -0,0 +1,13 @@ 
+// PR c++/57543
+// { dg-do compile { target c++11 } }
+
+template< typename T> struct X
+{
+  void foo();
+  auto bar() -> decltype( X::foo() );
+};
+
+int main()
+{
+  X<int>().bar();
+}