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.carl...@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.carl...@oracle.com>
PR c++/57543
* g++.dg/cpp0x/decltype59.C: New.
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();
+}