[cfe-commits] tgmath.h

Douglas Gregor dgregor at apple.com
Wed Feb 18 09:26:51 PST 2009


On Feb 18, 2009, at 7:48 AM, Howard Hinnant wrote:

> On Feb 18, 2009, at 2:10 AM, Douglas Gregor wrote:
>
>> On Feb 17, 2009, at 3:30 PM, Howard Hinnant wrote:
>>> Oh, and:
>>>
>>> -------------
>>> none of the above:
>>> -------------
>>> 81 lines of output starting with:
>>>
>>> test.c:7:8: error: no matching function for call to '__tg_promote'
>>>  x = acos(x);
>>>      ^~~~~~~
>>> ./tgmath.h:88:29: note: instantiated from:
>>> #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
>>>
>>> :-)
>>
>> I just added some more toys that should help improve this. First of  
>> all, I wired up the Objective-C "unavailable" attribute so that it  
>> works like a C++0x deleted function, e.g.,
>>
>> 	void f(int) __attribute__((__unavailable__));
>>
>> 	f(5); // error: called an unavailable function
>>
>> Second, we now allow "overloadable" functions in C to be variadic  
>> without any named parameters, e.g., this is well-formed
>>
>> 	void f(...) __attribute__((__overloaded__));
>>
>> I'm sure that'll help improve the diagnostics in tgmath.h :)
>>
>> 	- Doug
>
> That did help.  I'm not set up with write access.

We need to fix that. Chris?

> Index: lib/Headers/tgmath.h
> ===================================================================
> --- lib/Headers/tgmath.h	(revision 64913)
> +++ lib/Headers/tgmath.h	(working copy)
> @@ -37,6 +37,7 @@
>
> // promotion
>
> +static void __tg_promote(...) __attribute__ 
> ((__unavailable__,__overloadable__));
> static double               _TG_ATTRSp __tg_promote(int);
> static double               _TG_ATTRSp __tg_promote(unsigned int);
> static double               _TG_ATTRSp __tg_promote(long);


Committed, with a little twist:

   typedef void _Argument_type_is_not_arithmetic;
   static _Argument_type_is_not_arithmetic __tg_promote(...) \
     __attribute__((__unavailable__,__overloadable__));

We're recovering badly from failures when calling __tg_promote. I'm  
working on some parser/sema tweaks to improve the situation, and will  
send an updated error message when it's done.

	- Doug



More information about the cfe-commits mailing list