-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Only emit -Wmicrosoft-goto in C++ mode #138507
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
Conversation
Follow-up to llvm#138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
@llvm/pr-subscribers-clang Author: Hans Wennborg (zmodem) ChangesFollow-up to #138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension. Full diff: https://github.com/llvm/llvm-project/pull/138507.diff 2 Files Affected:
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 6d71b26801107..a852a950b47f4 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -998,7 +998,8 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
SmallVector<unsigned, 10> ToScopesError;
SmallVector<unsigned, 10> ToScopesWarning;
for (unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
- if (S.getLangOpts().MSVCCompat && JumpDiagWarning != 0 &&
+ if (S.getLangOpts().MSVCCompat && S.getLangOpts().CPlusPlus &&
+ JumpDiagWarning != 0 &&
IsMicrosoftJumpWarning(JumpDiagError, Scopes[I].InDiag))
ToScopesWarning.push_back(I);
else if (IsCXX98CompatWarning(S, Scopes[I].InDiag) ||
diff --git a/clang/test/Sema/warn-jump-bypasses-init.c b/clang/test/Sema/warn-jump-bypasses-init.c
index a9604742bf50c..53f10722406cd 100644
--- a/clang/test/Sema/warn-jump-bypasses-init.c
+++ b/clang/test/Sema/warn-jump-bypasses-init.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wjump-bypasses-init %s
// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wc++-compat %s
// RUN: %clang_cc1 -fsyntax-only -verify=good %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -fms-compatibility %s
// RUN: %clang_cc1 -fsyntax-only -verify=cxx,both -x c++ %s
// good-no-diagnostics
|
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 for catching this!
Follow-up to llvm#138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
Follow-up to llvm#138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
Follow-up to llvm#138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
Follow-up to llvm#138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
Follow-up to #138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.