diff options
author | Sirraide <aeternalmail@gmail.com> | 2025-09-02 18:37:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-02 16:37:19 +0000 |
commit | e4a1b5f36e71c8c382bdd531867c5f6eb3f7deac (patch) | |
tree | 5ed6131d9d0abadc4e4726509c3c01cdf264600d /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 83f390859e186d22af8aa32135d7993079ed4666 (diff) | |
download | llvm-e4a1b5f36e71c8c382bdd531867c5f6eb3f7deac.zip llvm-e4a1b5f36e71c8c382bdd531867c5f6eb3f7deac.tar.gz llvm-e4a1b5f36e71c8c382bdd531867c5f6eb3f7deac.tar.bz2 |
[Clang] [C2y] Implement N3355 ‘Named Loops’ (#152870)
This implements support for [named
loops](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm) for
C2y.
When parsing a `LabelStmt`, we create the `LabeDecl` early before we parse
the substatement; this label is then passed down to `ParseWhileStatement()`
and friends, which then store it in the loop’s (or switch statement’s) `Scope`;
when we encounter a `break/continue` statement, we perform a lookup for
the label (and error if it doesn’t exist), and then walk the scope stack and
check if there is a scope whose preceding label is the target label, which
identifies the jump target.
The feature is only supported in C2y mode, though a cc1-only option
exists for testing (`-fnamed-loops`), which is mostly intended to try
and make sure that we don’t have to refactor this entire implementation
when/if we start supporting it in C++.
---------
Co-authored-by: Balazs Benics <benicsbalazs@gmail.com>
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 29f9cf3..aadda69 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -623,6 +623,9 @@ static bool FixupInvocation(CompilerInvocation &Invocation, LangOpts.RawStringLiterals = true; } + LangOpts.NamedLoops = + Args.hasFlag(OPT_fnamed_loops, OPT_fno_named_loops, LangOpts.C2y); + // Prevent the user from specifying both -fsycl-is-device and -fsycl-is-host. if (LangOpts.SYCLIsDevice && LangOpts.SYCLIsHost) Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fsycl-is-device" |