[all-commits] [llvm/llvm-project] a87572: PR49585: Emit the jump destination for a for loop ...
Richard Smith via All-commits
all-commits at lists.llvm.org
Wed Mar 17 16:24:31 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a875721d8a2dacb894106a2cefa18828bf08f25d
https://github.com/llvm/llvm-project/commit/a875721d8a2dacb894106a2cefa18828bf08f25d
Author: Richard Smith <richard at metafoo.co.uk>
Date: 2021-03-17 (Wed, 17 Mar 2021)
Changed paths:
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Parse/Parser.h
M clang/include/clang/Sema/Scope.h
M clang/lib/CodeGen/CGStmt.cpp
M clang/lib/Parse/ParseExprCXX.cpp
M clang/lib/Parse/ParseStmt.cpp
M clang/lib/Sema/SemaStmt.cpp
A clang/test/CodeGenCXX/for-cond-var.cpp
M clang/test/Parser/cxx2a-init-statement.cpp
M clang/test/SemaCXX/scope-check.cpp
Log Message:
-----------
PR49585: Emit the jump destination for a for loop 'continue' from within the scope of the condition variable.
The condition variable is in scope in the loop increment, so we need to
emit the jump destination from wthin the scope of the condition
variable.
For GCC compatibility (and compatibility with real-world 'FOR_EACH'
macros), 'continue' is permitted in a statement expression within the
condition of a for loop, though, so there are two cases here:
* If the for loop has no condition variable, we can emit the jump
destination before emitting the condition.
* If the for loop has a condition variable, we must defer emitting the
jump destination until after emitting the variable. We diagnose a
'continue' appearing in the initializer of the condition variable,
because it would jump past the initializer into the scope of that
variable.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D98816
More information about the All-commits
mailing list