aaron.ballman added a comment.

In D134831#4141842 <https://reviews.llvm.org/D134831#4141842>, @samitolvanen 
wrote:

> In D134831#4137408 <https://reviews.llvm.org/D134831#4137408>, @inglorion 
> wrote:
>
>> Is this intended to warn on code that casts a function taking a pointer to 
>> some non-void type to a function that takes a void*?
>
> Yes, this is intended to warn if the function types don't match.
>
>> I didn't see this mentioned in the diff description, comments, or test. Is 
>> the behavior intentional? Are these types actually incompatible?
>
> As far as the language is concerned, the types are not incompatible, <snip>

As far as C and C++ are concerned, those types *are* incompatible.

C2x 6.7.6.3p14: For two function types to be compatible, both shall specify 
compatible return types. Moreover, the parameter type lists shall agree in the 
number of parameters and in use of the final ellipsis; corresponding parameters 
shall have compatible types. In the determination of type compatibility and of 
a composite type, each parameter declared with function or array type is taken 
as having the adjusted type and each parameter declared with qualified type is 
taken as having the unqualified version of its declared type.

6.7.6.1p2: For two pointer types to be compatible, both shall be identically 
qualified and both shall be pointers to compatible types.

6.2.7p1: Two types are compatible types if they are the same. Additional rules 
for determining whether two types are compatible are described in <snip>

`void *` and `int *` are not compatible types, so the function parameter lists 
are not compatible, so the function types are not compatible.

(Similar is in C++, though the specification mechanics are different.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134831/new/

https://reviews.llvm.org/D134831

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to