[flang-commits] [flang] [flang][Semantics] Check defined-operator purity at the use site (PR #229976)

Yusuke MINATO via flang-commits flang-commits at lists.llvm.org
Thu Oct 15 18:53:57 PDT 2026


https://github.com/yus3710-fj commented:

Thank you for your great work.

I'm concerned that the error message might be a bit confusing. The error message generated for the code in the issue will be as follows:

```
error: Semantic errors in test.f90
test.f90:54:9: error: Procedure 'pv_scale' referenced in pure subprogram 'midpoint' must be pure too
      r = 0.5 * (p + q)
          ^^^^^^^^^^^^^
test.f90:54:16: error: Procedure 'pv_add' referenced in pure subprogram 'midpoint' must be pure too
      r = 0.5 * (p + q)
                 ^^^^^
```

There are two issues with this:
1. The connection to the procedure is not immediately obvious.
2. The caret highlights unrelated parts of the expression.

This is just a suggestion, but perhaps we could change the message to something like this:

```
error: Procedure 'pv_scale' (as OPERATOR(*)) referenced in pure subprogram 'midpoint' must be pure too
```

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


More information about the flang-commits mailing list