[clang] [C] Add -Wjump-bypasses-init (PR #138009)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 05:08:54 PDT 2025
================
@@ -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-diagnostics
+
+void goto_func_1(void) {
----------------
AaronBallman wrote:
These are fun examples. It turns out that this code is accepted in both C and C++ despite jumping over the initialization, in both Clang and GCC. I'm not convinced that's a good design, but I don't think this patch changes the behavior either, and so I don't think we should diagnose. However, perhaps we should in a follow-up, so I've filed: https://github.com/llvm/llvm-project/issues/138257 and added these as negative tests for this PR.
https://github.com/llvm/llvm-project/pull/138009
More information about the cfe-commits
mailing list