Skip to content

Fix erroneous -Wmissing-prototypes for Win32 entry points #98105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,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
----------------------------------

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions clang/test/Sema/no-warn-missing-prototype.c
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Loading