[flang-commits] [flang] [flang][Semantics] Check defined-operator purity at the use site (PR #229976)
via flang-commits
flang-commits at lists.llvm.org
Mon Oct 19 21:07:13 PDT 2026
================
@@ -12,8 +12,210 @@ impure integer function func(x)
class(t), intent(in) :: x
func = 0
end
- pure integer function test
+ pure integer function pure_id(n)
+ integer, intent(in) :: n
+ pure_id = n
+ end
+ pure integer function test()
+ ! A direct call to a pure procedure is allowed.
+ test = pure_id(1)
!ERROR: Procedure 'func' referenced in pure subprogram 'test' must be pure too
test = .not. t()
end
end
+
+! F2023 C1595: a procedure referenced from a pure subprogram must be pure,
+! including references through defined operators (binary, unary, named,
+! and relational). The operator's generic is declared where its interface
+! block appears; the purity check must be anchored at the use site instead,
+! so each reference is diagnosed independently and the message points at
+! the call, not at the (possibly distant, possibly single) declaration.
----------------
shivaramaarao wrote:
Thank you. this is corrected now.
https://github.com/llvm/llvm-project/pull/229976
More information about the flang-commits
mailing list