aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authors-watanabe314 <watanabe.shu-06@fujitsu.com>2024-09-03 13:22:33 +0900
committerGitHub <noreply@github.com>2024-09-03 13:22:33 +0900
commit78abeca1d88593d7f2a27f3c3e140abe77236e7e (patch)
treef31e0ab45acfb9d9e9c2e351e8370427b4731c59 /llvm/lib/CodeGen/MachinePipeliner.cpp
parent2cbd1bc830861bc08f78fb6cc11747b82f66c4c6 (diff)
downloadllvm-78abeca1d88593d7f2a27f3c3e140abe77236e7e.zip
llvm-78abeca1d88593d7f2a27f3c3e140abe77236e7e.tar.gz
llvm-78abeca1d88593d7f2a27f3c3e140abe77236e7e.tar.bz2
[clang][Sema] Fix diagnostic for function overloading in extern "C" (#106033)
Fixes #80235 When trying to overload a function within `extern "C"`, the diagnostic `functions that differ only in their return type cannot be overloaded` is given. This diagnostic is inappropriate because overloading is basically not allowed in the C language. However, if the redeclared function has the `((overloadable))` attribute, it should be diagnosed as `functions that differ only in their return type cannot be overloaded`. This patch uses `isExternC()` to provide an appropriate diagnostic during the diagnostic process. `isExternC()` updates the linkage information cache internally, so calling it before merging functions can cause clang to crash. An example is declaring `static void foo()` and `void foo()` within an `extern "C"` block. Therefore, I decided to call `isExternC()` after the compilation error is confirmed and select the diagnostic message. The diagnostic message is `conflicting types for 'func'` similar to the diagnostic in C, and `functions that differ only in their return type cannot be overloaded` if the `((overloadable))` attribute is given. Regression tests verify that the expected diagnostics are given when trying to overload functions within `extern "C"` and when the `((overloadable))` attribute is present. --------- Co-authored-by: Sirraide <aeternalmail@gmail.com>
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
0 files changed, 0 insertions, 0 deletions