[flang-commits] [flang] [flang][OpenMP] Validate substrings (PR #234661)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Fri Oct 23 03:10:27 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()};
----------------
tblah wrote:
I've added some comments and renamed the function to `IsSubstringAndValidate` to make this clearer
https://github.com/llvm/llvm-project/pull/234661
More information about the flang-commits
mailing list