===================================================================
@@ -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)
===================================================================
@@ -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();
+}