[flang-commits] [flang] [flang] Enforce F'2023 C15121 (PR #94418)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 5 07:58:48 PDT 2024
================
@@ -243,6 +243,31 @@ void CheckHelper::Check(
}
}
+// Checks an elemental function result type parameter specification
+// expression for an unacceptable use of a dummy argument.
+class BadDummyChecker : public evaluate::AnyTraverse<BadDummyChecker, bool> {
+public:
+ using Base = evaluate::AnyTraverse<BadDummyChecker, bool>;
+ BadDummyChecker(parser::ContextualMessages &messages, const Scope &scope)
+ : Base{*this}, messages_{messages}, scope_{scope} {}
+ using Base::operator();
+ bool operator()(const evaluate::DescriptorInquiry &) {
+ return false; // shield base() of inquiry from further checking
+ }
----------------
jeanPerier wrote:
Isn't this technically too restrictive since not all inquiry intrinsics are lowered to evaluate::DescriptorInquiry.
```
A specification inquiry is a reference to:
(1) an intrinsic inquiry function other than PRESENT,
(2) a type parameter inquiry (9.4.5),
(3) an inquiry function from the intrinsic modules IEEE_ARITHMETIC and IEEE_EXCEPTIONS (17.10),
(4) the function C_SIZEOF from the intrinsic module ISO_C_BINDING (18.2.3.8), or
(5) the COMPILER_VERSION or COMPILER_OPTIONS function from the intrinsic module ISO_FORTRAN_ENV (16.10.2.6, 16.10.2.7).
```
For instance, I think the following does not violate C15121:
```
interface
elemental function funny(x)
class(*), intent(in) :: x
character(STORAGE_SIZE(x)/8) :: funny
end function
end interface
end
```
https://github.com/llvm/llvm-project/pull/94418
More information about the flang-commits
mailing list