[flang-commits] [flang] [flang][OpenMP] Validate substrings (PR #234661)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Thu Oct 22 08:46:14 PDT 2026


================
@@ -327,13 +327,18 @@ bool IsVariableListItem(
   return false;
 }
 
-bool IsSubstring(const parser::OmpObject &object, SemanticsContext *semaCtx) {
-  if (auto *desg{GetDesignatorFromObj(object)}) {
+std::optional<bool> IsSubstring(
+    const parser::OmpObject &object, SemanticsContext *semaCtx) {
+  // Whole objects and other designators cannot be substrings. Analyzing them
+  // as expressions can reject otherwise valid OpenMP list items.
+  if (auto *desg{GetDesignatorFromObj(object)}; desg &&
+      (std::holds_alternative<parser::Substring>(desg->u) ||
+          GetArrayElementFromObj(object))) {
     evaluate::ExpressionAnalyzer ea(*semaCtx);
-    auto restorer{ea.GetContextualMessages().DiscardMessages()};
----------------
kparzysz wrote:

Why is this deleted?  This function should not emit any messages.

https://github.com/llvm/llvm-project/pull/234661


More information about the flang-commits mailing list