[PATCH] D131351: [C] Default implicit function pointer conversions diagnostic to be an error

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 12 11:15:29 PDT 2022


aaron.ballman added a comment.

In D131351#3718728 <https://reviews.llvm.org/D131351#3718728>, @mizvekov wrote:

> In D131351#3718725 <https://reviews.llvm.org/D131351#3718725>, @aaron.ballman wrote:
>
>> However, we don't care about the type mismatch when doing a redeclaration or when dropping the attribute, as in:
>>
>>   __attribute__((noreturn)) void my_exit(void);
>>   void (*handler)(void) = my_exit; // Silently drops the attribute
>>   
>>   _Noreturn void my_exit(void) { // No concerns about the type mismatch on redeclaration because we inherit __attribute__((noreturn))
>>   }
>>
>> so maybe we shouldn't worry about it here.
>
> Are you sure? If the function types don't match in C++, I would expect that to become a different overload, not a redeclaration, right?

The changes here only impact C so it shouldn't be a big deal, but we do not create an overload set for them in C with the `overloadable` attribute: https://godbolt.org/z/1ETe6ff5s

I tracked down the `noreturn` behavior and this turns out to be intentional for the past ten years and is a result of a bug report I can't see: https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L1526 (https://github.com/llvm/llvm-project/commit/48c69106e4ce1 was what added the functionality.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131351



More information about the cfe-commits mailing list