[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > this causes a `-Wmicrosoft-goto` warning on > > ``` > $ cat /tmp/a.c > void f() { > goto l; > int i = 0; > l: > } > $ bin/clang-cl /c /tmp/a.c > ... > /tmp/a.c(2,2): warning: jump from this goto statement to its label is a > Microsoft extension [-Wmicrosoft

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-05 Thread Hans Wennborg via cfe-commits
zmodem wrote: > this causes a `-Wmicrosoft-goto` warning on [...] Sent https://github.com/llvm/llvm-project/pull/138507 for this. https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Just FYI, the GCC name of the option is `-Wjump-misses-init` (since GCC > 4.5.0). Oh good to know, thank you! https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Andrew Pinski via cfe-commits
pinskia wrote: Just FYI, the GCC name of the option is -Wjump-misses-init . https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Arthur Eubanks via cfe-commits
aeubanks wrote: this causes a `-Wmicrosoft-goto` warning on ``` $ cat /tmp/a.c void f() { goto l; int i = 0; l: } $ bin/clang-cl /c /tmp/a.c ... /tmp/a.c(2,2): warning: jump from this goto statement to its label is a Microsoft extension [-Wmicrosoft-goto] 2 | goto l;

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138009 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
@@ -6561,18 +6561,28 @@ def ext_goto_into_protected_scope : ExtWarn< def warn_cxx98_compat_goto_into_protected_scope : Warning< "jump from this goto statement to its label is incompatible with C++98">, InGroup, DefaultIgnore; +def warn_cpp_compat_goto_into_protected_scope :

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,31 @@ +// 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=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman deleted https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,31 @@ +// 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=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman deleted https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-02 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,31 @@ +// 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=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -6561,18 +6561,28 @@ def ext_goto_into_protected_scope : ExtWarn< def warn_cxx98_compat_goto_into_protected_scope : Warning< "jump from this goto statement to its label is incompatible with C++98">, InGroup, DefaultIgnore; +def warn_cpp_compat_goto_into_protected_scope :

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,31 @@ +// 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=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,31 @@ +// 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=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. Please add a test for the new indirect goto diagnostic. Otherwise LGTM https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138009 >From e626293edbba69d0627181b9118aff795bd4173b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 30 Apr 2025 14:20:03 -0400 Subject: [PATCH 1/2] [C] Add -Wjump-bypasses-init We already diagnose when

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Aaron Ballman via cfe-commits
@@ -560,13 +560,14 @@ LABEL3:{} // #GOTOLBL3 void IndirectGoto3_Loop() { void* ptr; #pragma acc parallel loop// #GOTOPAR_LOOP3 - for (unsigned i = 0; i < 5; ++i) { + for (unsigned i = 0; i < 5; ++i) { // #INIT LABEL3:{} // #GOTOLBL3_2 ptr = &&LABEL3; } -// expected

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread Eli Friedman via cfe-commits
@@ -560,13 +560,14 @@ LABEL3:{} // #GOTOLBL3 void IndirectGoto3_Loop() { void* ptr; #pragma acc parallel loop// #GOTOPAR_LOOP3 - for (unsigned i = 0; i < 5; ++i) { + for (unsigned i = 0; i < 5; ++i) { // #INIT LABEL3:{} // #GOTOLBL3_2 ptr = &&LABEL3; } -// expected

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138009 >From e626293edbba69d0627181b9118aff795bd4173b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 30 Apr 2025 14:20:03 -0400 Subject: [PATCH 1/2] [C] Add -Wjump-bypasses-init We already diagnose when

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Frightening how few tests this breaks, but LGTM. We don't enable `-Wc++-compat` for many of our tests, so the fallout isn't terrible; just impacts the tests where jump diagnostics were already enabled for C (which isn't often). https://github.com/llvm/llvm-project/pull/1

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. Frightening how few tests this breaks, but LGTM. https://github.com/llvm/llvm-project/pull/138009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions c,cpp -- clang/test/Sema/warn-jump-bypasses-init.c clang/lib

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes We already diagnose when a jump bypasses initialization in C++ because such code is ill-formed there. However, we were not using this to diagnose those same jumps in C. -Wjump-bypasses-init is grouped

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-04-30 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/138009 We already diagnose when a jump bypasses initialization in C++ because such code is ill-formed there. However, we were not using this to diagnose those same jumps in C. -Wjump-bypasses-init is grouped und