https://github.com/MaxEW707 updated https://github.com/llvm/llvm-project/pull/98105
>From f9def27dcbfe6ce1a55fd5c41d15d55b05d9a056 Mon Sep 17 00:00:00 2001 From: MaxEW707 <max.enrico.wink...@gmail.com> Date: Mon, 8 Jul 2024 19:14:11 -0700 Subject: [PATCH 1/4] Fix erroneous `-Wmissing-prototypes` for Win32 entry points --- clang/lib/Sema/SemaDecl.cpp | 3 +++ clang/test/Sema/no-warn-missing-prototype.c | 27 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b3bfdacb01790..b4d8d653616b1 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -15214,6 +15214,9 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, if (II->isStr("main") || II->isStr("efi_main")) return false; + if (FD->isMSVCRTEntryPoint()) + return false; + // Don't warn about inline functions. if (FD->isInlined()) return false; diff --git a/clang/test/Sema/no-warn-missing-prototype.c b/clang/test/Sema/no-warn-missing-prototype.c index 6059b6aa0f146..577718c928e59 100644 --- a/clang/test/Sema/no-warn-missing-prototype.c +++ b/clang/test/Sema/no-warn-missing-prototype.c @@ -1,10 +1,33 @@ // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c -ffreestanding -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s // expected-no-diagnostics int main() { - return 0; + return 0; } int efi_main() { - return 0; + return 0; } + +#ifdef MS +int wmain(int, wchar_t *[], wchar_t *[]) +{ + return 0; +} + +int wWinMain(void*, void*, wchar_t*, int) +{ + return 0; +} + +int WinMain(void*, void*, char*, int) +{ + return 0; +} + +bool DllMain(void*, unsigned, void*) +{ + return true; +} +#endif \ No newline at end of file >From 1143a06a4b4b7f435c19325bd3b2253cde02372c Mon Sep 17 00:00:00 2001 From: MaxEW707 <max.enrico.wink...@gmail.com> Date: Mon, 8 Jul 2024 19:19:07 -0700 Subject: [PATCH 2/4] formatting --- clang/test/Sema/no-warn-missing-prototype.c | 26 +++++++++------------ 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/clang/test/Sema/no-warn-missing-prototype.c b/clang/test/Sema/no-warn-missing-prototype.c index 577718c928e59..1b6e8f059fc45 100644 --- a/clang/test/Sema/no-warn-missing-prototype.c +++ b/clang/test/Sema/no-warn-missing-prototype.c @@ -3,31 +3,27 @@ // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s // expected-no-diagnostics int main() { - return 0; + return 0; } int efi_main() { - return 0; + return 0; } #ifdef MS -int wmain(int, wchar_t *[], wchar_t *[]) -{ - return 0; +int wmain(int, wchar_t *[], wchar_t *[]) { + return 0; } -int wWinMain(void*, void*, wchar_t*, int) -{ - return 0; +int wWinMain(void*, void*, wchar_t*, int) { + return 0; } -int WinMain(void*, void*, char*, int) -{ - return 0; +int WinMain(void*, void*, char*, int) { + return 0; } -bool DllMain(void*, unsigned, void*) -{ - return true; +bool DllMain(void*, unsigned, void* { + return true; } -#endif \ No newline at end of file +#endif >From bc40af777e31df856de3c68fe749311c8011f21f Mon Sep 17 00:00:00 2001 From: MaxEW707 <max.enrico.wink...@gmail.com> Date: Mon, 8 Jul 2024 19:26:29 -0700 Subject: [PATCH 3/4] fix unit test --- clang/test/Sema/no-warn-missing-prototype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/Sema/no-warn-missing-prototype.c b/clang/test/Sema/no-warn-missing-prototype.c index 1b6e8f059fc45..17d69ac8913fa 100644 --- a/clang/test/Sema/no-warn-missing-prototype.c +++ b/clang/test/Sema/no-warn-missing-prototype.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c -ffreestanding -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s -// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s // expected-no-diagnostics int main() { return 0; @@ -23,7 +23,7 @@ int WinMain(void*, void*, char*, int) { return 0; } -bool DllMain(void*, unsigned, void* { +bool DllMain(void*, unsigned, void*) { return true; } #endif >From 5ca6a7feeebdf1db1f79353873e946c990ab4494 Mon Sep 17 00:00:00 2001 From: MaxEW707 <max.enrico.wink...@gmail.com> Date: Mon, 8 Jul 2024 19:34:49 -0700 Subject: [PATCH 4/4] Add Release Note --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 36cf615a4287c..0f67a4ed4ea96 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -654,6 +654,9 @@ Improvements to Clang's diagnostics - Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393. +- Clong no longer emits a no previous prototype warning for Win32 entry points under ``-Wmissing-prototypes``. + Fixes #GH94366. + Improvements to Clang's time-trace ---------------------------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits