[all-commits] [llvm/llvm-project] 3578fa: [clang][OpenMP] Fix statement expressions in loop ...
Akash Manna via All-commits
all-commits at lists.llvm.org
Tue Sep 22 04:16:54 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3578fa36b62dc4355225bd6859c0c098f52c29d4
https://github.com/llvm/llvm-project/commit/3578fa36b62dc4355225bd6859c0c098f52c29d4
Author: Akash Manna <akash.manna.mymail at gmail.com>
Date: 2026-09-22 (Tue, 22 Sep 2026)
Changed paths:
M clang/docs/ReleaseNotes.md
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaOpenMP.cpp
A clang/test/OpenMP/for_collapse_stmt_expr_codegen.cpp
M clang/test/OpenMP/for_loop_messages.cpp
Log Message:
-----------
[clang][OpenMP] Fix statement expressions in loop bounds being emitted more than once (#224939)
Fixes #153987
When Sema builds the helper expressions for an OpenMP loop, a bound that
evaluates to a constant is reused directly instead of being captured
into a `.capture_expr.` variable, so the same expression node is spliced
into the init, update, final and precondition helpers. That is fine for
`10 + 1`, but a statement expression like `({int a = 0; 0;})` declares a
variable, and emitting the shared node several times re-declares `a` and
trips `Decl already exists in LocalDeclMap!` in CodeGen. The report only
looked like a bytecode-interpreter issue because the old evaluator
happened to refuse `({float a = 0; a;})` and the new one didn't; the
unused-variable form crashes with both.
The capture decision now treats any expression containing a statement
expression as non-constant, so it goes through the existing capture
path: evaluated once in the pre-init statement, with every helper
reading the captured value. A bound of a non-rectangular loop can't be
captured at all, since it is re-evaluated at every use and the original
condition doubles as the body guard, so a statement expression there is
now rejected with an error, as GCC already does.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list