[cxx-abi-dev] Parameter references in function types

David Vandevoorde daveed at edg.com
Tue Jun 15 15:49:17 UTC 2010


On Jun 14, 2010, at 1:10 PM, Jason Merrill wrote:

> On 05/06/2010 03:48 PM, David Vandevoorde wrote:
>> Let L be the number of function prototype scopes from the innermost one (in which the parameter reference occurs) up to (and including) the one containing the declaration of the referenced parameter.  If the parameter declaration clause of the innermost function prototype scope has been completely seen, it is not counted (in that case -- which is perhaps the most common -- L can be zero).
> 
> I agree with the general idea, but would quibble with the specification; the innermost scope should be #0, and the return type should be considered part of the prototype. So:
> 
>> 	template<class T, class U> void f(T p, decltype(p)(*)(U p));          // L = 1
> 
> Yes.
> 
>> 	template<class T, class U> void f(T p, auto (*)(U p)->decltype(p));   // L = 0
> 
> Yes.
> 
>> 	template<class T>  void f(T p, decltype(p));                // L = 1
> 
> L = 0.



At first we tried it like that, but it turns out to be a pain: You really want the first case above and this one to have the same L value.  Otherwise, you cannot assign the L value when you parse the type, and instead have to wait until you have parsed the whole parameter (and by then you may already have used the type in all kinds of other contexts that have needed the mangled name).  

	Daveed


> 
>> 	template<class T>  void g(T p, decltype(p) (*)());          // L = 1
> 
> Yes.
> 
>> 	template<class T>  void h(T p, auto (*)()->decltype(p));    // L = 1
> 
> Yes.
> 
>> 	template<class T>  void i(T p, auto (*)(T q)->decltype(q)); // L = 0
> 
> Yes.
> 
>> 	template<class T>  void j(T p, auto (*)(decltype(p))->T);   // L = 2
> 
> L = 1.
> 
>> 	template<class T>  void k(T p, int (*(*)(T p))[sizeof(p)]); // L = 1
> 
> Yes; sizeof(p) refers to the outer p.
> 
> Jason




More information about the cxx-abi-dev mailing list