Skip to content

Commit b0b96fb

Browse files
authored
Fix erroneous -Wmissing-prototypes for Win32 entry points (#98105)
Fixes #94366.
1 parent 46c7da6 commit b0b96fb

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@ Improvements to Clang's diagnostics
686686

687687
- Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393.
688688

689+
- Clang no longer emits a "no previous prototype" warning for Win32 entry points under ``-Wmissing-prototypes``.
690+
Fixes #GH94366.
691+
689692
Improvements to Clang's time-trace
690693
----------------------------------
691694

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15222,6 +15222,9 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
1522215222
if (II->isStr("main") || II->isStr("efi_main"))
1522315223
return false;
1522415224

15225+
if (FD->isMSVCRTEntryPoint())
15226+
return false;
15227+
1522515228
// Don't warn about inline functions.
1522615229
if (FD->isInlined())
1522715230
return false;

clang/test/Sema/no-warn-missing-prototype.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c -ffreestanding -verify %s
22
// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s
3+
// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s
34
// expected-no-diagnostics
45
int main() {
56
return 0;
@@ -8,3 +9,21 @@ int main() {
89
int efi_main() {
910
return 0;
1011
}
12+
13+
#ifdef MS
14+
int wmain(int, wchar_t *[], wchar_t *[]) {
15+
return 0;
16+
}
17+
18+
int wWinMain(void*, void*, wchar_t*, int) {
19+
return 0;
20+
}
21+
22+
int WinMain(void*, void*, char*, int) {
23+
return 0;
24+
}
25+
26+
bool DllMain(void*, unsigned, void*) {
27+
return true;
28+
}
29+
#endif

0 commit comments

Comments
 (0)