Skip to content

Conversation

@klausler
Copy link
Contributor

Don't increment the LHS variable of an assignment that also uses that variable on the RHS.

Don't increment the LHS variable of an assignment that also
uses that variable on the RHS.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jul 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 18, 2025

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

Don't increment the LHS variable of an assignment that also uses that variable on the RHS.


Full diff: https://github.com/llvm/llvm-project/pull/149549.diff

1 Files Affected:

  • (modified) flang/lib/Semantics/resolve-labels.cpp (+3-4)
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index 27e259fab38738..9454ef9fe928ad 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -492,10 +492,9 @@ class ParseTreeAnalyzer {
     // Uppercase the name of the main program, so that its symbol name
     // would be unique from similarly named non-main-program symbols.
     auto upperCaseCharBlock = [](const parser::CharBlock &cb) {
-      char *ch{const_cast<char *>(cb.begin())};
-      char *endCh{ch + cb.size()};
-      while (ch != endCh) {
-        *ch++ = parser::ToUpperCaseLetter(*ch);
+      auto ch{const_cast<char *>(cb.begin())};
+      for (char *endCh{ch + cb.size()}; ch != endCh; ++ch) {
+        *ch = parser::ToUpperCaseLetter(*ch);
       }
     };
     const parser::CharBlock *progName{nullptr};

@klausler klausler merged commit b6ea04a into llvm:main Jul 18, 2025
12 checks passed
@klausler klausler deleted the fix-warning branch July 18, 2025 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants