[clang] [Sema] Diagnose use of if/else-if condition variable inside else-if/else branch(s) (PR #156436)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 3 13:22:38 PDT 2025
================
@@ -13660,10 +13594,11 @@ def warn_acc_var_referenced_lacks_op
"reference has no effect">,
InGroup<DiagGroup<"openacc-var-lacks-operation">>,
DefaultError;
+def warn_out_of_scope_var_usage
+ : Warning<"variable %0 declared in 'if' block is always false or null here">,
+ InGroup<DiagGroup<"conditional-scope">>;
----------------
arrowten wrote:
>Not really a fan of this wording. Perhaps we could use a %select here to decide whether this is a false or null (or perhaps even 0?). Or perhaps we should just say false always? What do others think?
I will try that.
>Also, a note pointing to the condition-var is probably a good idea too.
Its pointing to the "used" condition variable though.
https://github.com/llvm/llvm-project/pull/156436
More information about the cfe-commits
mailing list