[clang] [Clang] Initialize bypassed variables w/ trivial-auto-var-init (PR #181937)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 18:01:58 PDT 2026
================
@@ -1749,6 +1757,8 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S,
// switch machinery to enter this block.
llvm::BasicBlock *CaseDest = createBasicBlock("sw.bb");
EmitBlockWithFallThrough(CaseDest, &S);
+ if (getLangOpts().CPlusPlus)
----------------
efriedma-quic wrote:
Getting computed goto right is more complicated.
The basic problem with computed goto is that you don't know if the jump left the scope of a variable. If you have a goto where the source and destination are in the same scope as a variable, the variable stays alive, and we must not reinitialize it. But unlike regular goto, we can't insert code along the edge.
So really, I suspect the best we can do for that case is treat every variable as if it's function scope. (Theoretically, there are ways to make it work, but they involve inserting extra code to track state, which would probably make anyone using computed goto unhappy.)
We need some test coverage with computed goto with multiple scopes.
https://github.com/llvm/llvm-project/pull/181937
More information about the cfe-commits
mailing list