[clang] [Sema] Diagnose use of if/else-if condition variable inside else-if/else branch(s) (PR #156436)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 3 14:05:30 PDT 2025


================
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_1 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_2 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_3 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_4 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_5 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope -DTEST_6 %s
+
+int *get_something();
+int *get_something_else();
+int *get_something_else_again();
+int *get_something_else_again_now();
+
+#ifdef TEST_1
----------------
erichkeane wrote:

Not necessarily.  But you can capture multiple diagnostics in the same run, so don't do macros, just do multiple checks.

https://github.com/llvm/llvm-project/pull/156436


More information about the cfe-commits mailing list