[C++ Patch] DR 217 follow up (and more)

Jason Merrill jason@redhat.com
Fri Aug 1 18:30:00 GMT 2014


On 07/31/2014 01:36 PM, Paolo Carlini wrote:
> The problem is that when grokfndecl calls duplicate_decls in such member cases it looks through TEMPLATE_DECLs
> and then telling apart the two cases above is tough, both are FUNCTION_DECLs
>
> Ideas about the best way to handle that?

Could you just condition it on DECL_TEMPLATE_INFO?

>  	  tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
>  	  int i = 1;
>
> -	  if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
> +	  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (newdecl))
>  	    t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);

Let's use FUNCTION_FIRST_USER_PARMTYPE instead.

> -	  if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE
> +	  if (DECL_FUNCTION_MEMBER_P (newdecl)

This change is OK.

and in the predicate patch:

> -	      || TREE_CODE (TREE_TYPE (target_type)) != METHOD_TYPE);
> +	      || !DECL_NONSTATIC_MEMBER_FUNCTION_P (target_type));

This is wrong because target_type is not a FUNCTION_DECL.  We should 
probably either add FUNCTION_DECL_CHECK to 
DECL_NONSTATIC_MEMBER_FUNCTION_P or make it false if the argument isn't 
a FUNCTION_DECL.

There are a bunch of instances of this in the patch.

>    if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE
> -      || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
> +      || DECL_NONSTATIC_MEMBER_FUNCTION_P (expr)

Changing this instance and similar ones doesn't make much sense since 
the condition is looking for any kind of function, not just a non-static 
member function.

Jason



More information about the Gcc-patches mailing list