-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
MaxEW707
merged 5 commits into
llvm:main
from
MaxEW707:mwinkler/fix-missing-prototypes-win32-mains
Jul 10, 2024
Merged
Fix erroneous -Wmissing-prototypes
for Win32 entry points
#98105
MaxEW707
merged 5 commits into
llvm:main
from
MaxEW707:mwinkler/fix-missing-prototypes-win32-mains
Jul 10, 2024
+25
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang Author: Max Winkler (MaxEW707) ChangesFixes #94366. Full diff: https://github.com/llvm/llvm-project/pull/98105.diff 2 Files Affected:
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..1b6e8f059fc45 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 -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
|
AaronBallman
approved these changes
Jul 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
nico
reviewed
Jul 9, 2024
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #94366.