Author: Max Winkler Date: 2024-07-09T18:38:32-07:00 New Revision: b0b96fbff47c74940a62073c579372f3c47df9c8
URL: https://github.com/llvm/llvm-project/commit/b0b96fbff47c74940a62073c579372f3c47df9c8 DIFF: https://github.com/llvm/llvm-project/commit/b0b96fbff47c74940a62073c579372f3c47df9c8.diff LOG: Fix erroneous `-Wmissing-prototypes` for Win32 entry points (#98105) Fixes https://github.com/llvm/llvm-project/issues/94366. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDecl.cpp clang/test/Sema/no-warn-missing-prototype.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fac4c8e69dc15..3b105d91958cc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -686,6 +686,9 @@ Improvements to Clang's diagnostics - Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393. +- Clang no longer emits a "no previous prototype" warning for Win32 entry points under ``-Wmissing-prototypes``. + Fixes #GH94366. + Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index aa44608035538..97e1f7e05e44e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -15222,6 +15222,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..17d69ac8913fa 100644 --- a/clang/test/Sema/no-warn-missing-prototype.c +++ b/clang/test/Sema/no-warn-missing-prototype.c @@ -1,5 +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 -Wmissing-prototypes -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s // expected-no-diagnostics int main() { return 0; @@ -8,3 +9,21 @@ int main() { int efi_main() { 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits