[cfe-commits] [PATCH] Merge function types is C.

Rafael Espíndola rafael.espindola at gmail.com
Wed Nov 28 20:04:22 PST 2012


> void f(int (*)[10]);
> void f(int (*)[]);
> void g() {
>   int x[5];
>   f(&x);
> }
>
> gcc gives "warning: passing argument 1 of ‘f’ from incompatible
> pointer type"; clang should print a similar warning.

Added. This required changing/fixing initialization sequences to use
the type from the function prototype instead of the one from the
argument.

>> What is the behavior you would expect from CodeGen? Given
>>
>> void f(int);
>> void f(a)
>>   char a;
>> {
>>   int v[sizeof(a) == 1 ? 1 : -1];
>> }
>>
>> Should it produce a f(i32) that truncates its argument?
>
> Yes, this should continue to work the same way it works on trunk.

A new patch is attached. The codegen is not identical in all cases,
for example, given

int svc_register (void (*dispatch) (int));
int svc_register (dispatch)
     void (*dispatch) ();
{}

without this patch we produce "@svc_register(void (...)* %dispatch)"
and with it we produce "@svc_register(void (i32)*)", which I think is
the desired result.

> -Eli

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 5846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121128/032e48a4/attachment.obj>


More information about the cfe-commits mailing list