diff mbox

[C++1y] Fix PR c++/58500

Message ID 0dc1c55f8eb864d8b145b798a43ec3c7@imap.force9.net
State New
Headers show

Commit Message

Adam Butcher Sept. 23, 2013, 7:08 a.m. UTC
Hi,

This fixes using 'auto' in the return type of a function pointer to 
introduce an implicit function template parameter.

Note that this doesn't mean that 'auto' parameters in a function ptr 
will be treated the same; I think we need a special case for this in the 
implicit template parameter introduction code (or refactor to generate 
template parm types on the fly).

Cheers,
Adam


     gcc/cp/
     	PR c++/58500
     	* type-utils.h (find_type_usage) Only traverse one type level into
     	member function pointers.

     gcc/testsuite/
     	PR c++/58500
     	* g++.dg/cpp1y/pr58500.C: New testcase.

Comments

Jason Merrill Sept. 23, 2013, 6:02 p.m. UTC | #1
On 09/23/2013 02:08 AM, Adam Butcher wrote:
> Note that this doesn't mean that 'auto' parameters in a function ptr
> will be treated the same; I think we need a special case for this in the
> implicit template parameter introduction code (or refactor to generate
> template parm types on the fly).

It is seeming like generating the types on the fly will make various 
things simpler; otherwise we need to deal with rewriting arbitrarily 
complex types later on.

The patch is OK.

Jason
Adam Butcher Sept. 23, 2013, 6:52 p.m. UTC | #2
On 23.09.2013 19:02, Jason Merrill wrote:
> On 09/23/2013 02:08 AM, Adam Butcher wrote:
>> Note that this doesn't mean that 'auto' parameters in a function ptr
>> will be treated the same; I think we need a special case for this in 
>> the
>> implicit template parameter introduction code (or refactor to 
>> generate
>> template parm types on the fly).
>
> It is seeming like generating the types on the fly will make various
> things simpler; otherwise we need to deal with rewriting arbitrarily
> complex types later on.
>
Agreed.  We can arrange for the parm trees to be as if the user had 
explicitly specified the template and then subsequent logic will proceed 
'naturally'.  I'll look into it.
diff mbox

Patch

diff --git a/gcc/cp/type-utils.h b/gcc/cp/type-utils.h
index 3e82ca4..2febce7 100644
--- a/gcc/cp/type-utils.h
+++ b/gcc/cp/type-utils.h
@@ -47,7 +47,7 @@  find_type_usage (tree t, bool (*pred) (const_tree))

    if (TYPE_PTRMEMFUNC_P (t))
      return find_type_usage
-      (TREE_TYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t))), pred);
+      (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t)), pred);

    return NULL_TREE;
  }
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58500.C 
b/gcc/testsuite/g++.dg/cpp1y/pr58500.C
new file mode 100644
index 0000000..b9d4a26
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr58500.C
@@ -0,0 +1,8 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++1y" }
+
+// PR c++/58500
+
+struct A {};
+
+void foo(auto (A::*)());