Skip to content

Commit a94e560

Browse files
authored
Only emit -Wmicrosoft-goto in C++ mode (#138507)
Follow-up to #138009 which added diagnostics for "jump past initialization" in C mode, in which case they're not an MS extension.
1 parent b06a014 commit a94e560

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Sema/JumpDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
998998
SmallVector<unsigned, 10> ToScopesError;
999999
SmallVector<unsigned, 10> ToScopesWarning;
10001000
for (unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
1001-
if (S.getLangOpts().MSVCCompat && JumpDiagWarning != 0 &&
1001+
if (S.getLangOpts().MSVCCompat && S.getLangOpts().CPlusPlus &&
1002+
JumpDiagWarning != 0 &&
10021003
IsMicrosoftJumpWarning(JumpDiagError, Scopes[I].InDiag))
10031004
ToScopesWarning.push_back(I);
10041005
else if (IsCXX98CompatWarning(S, Scopes[I].InDiag) ||

clang/test/Sema/warn-jump-bypasses-init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wjump-misses-init %s
22
// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wc++-compat %s
33
// RUN: %clang_cc1 -fsyntax-only -verify=good %s
4+
// RUN: %clang_cc1 -fsyntax-only -verify=good -fms-compatibility %s
45
// RUN: %clang_cc1 -fsyntax-only -verify=cxx,both -x c++ %s
56
// good-no-diagnostics
67

0 commit comments

Comments
 (0)