xref: /llvm-project/flang/runtime/non-tbp-dio.h (revision 0cda970ecc8a885acf7298a61370a1368b0ea39b)
1 //===-- flang/runtime/non-tbp-dio.h -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // Defines a structure used to identify the non-type-bound defined I/O
10 // generic interfaces that are accessible in a particular scope.  This
11 // table is used by some I/O APIs and is also part of the NAMELIST
12 // group table.
13 //
14 // A specific procedure for a particular derived type must appear in
15 // this table if it (a) is a dummy procedure or procedure pointer,
16 // (b) is part of the defined I/O generic definition in a scope other
17 // than the one that contains the derived type definition, or (c)
18 // is a null pointer signifying that some specific procedure from
19 // a containing scope has become inaccessible in a nested scope due
20 // to the use of "IMPORT, NONE" or "IMPORT, ONLY:".
21 
22 #ifndef FORTRAN_RUNTIME_NON_TBP_DIO_H_
23 #define FORTRAN_RUNTIME_NON_TBP_DIO_H_
24 
25 #include "flang/Common/Fortran-consts.h"
26 #include "flang/Common/api-attrs.h"
27 #include <cstddef>
28 
29 namespace Fortran::runtime::typeInfo {
30 class DerivedType;
31 } // namespace Fortran::runtime::typeInfo
32 
33 namespace Fortran::runtime::io {
34 
35 struct NonTbpDefinedIo {
36   const typeInfo::DerivedType &derivedType;
37   void (*subroutine)(); // null means no non-TBP defined I/O here
38   common::DefinedIo definedIo;
39   bool isDtvArgPolymorphic; // first dummy arg is CLASS(T)
40 };
41 
42 struct NonTbpDefinedIoTable {
43   RT_API_ATTRS const NonTbpDefinedIo *Find(
44       const typeInfo::DerivedType &, common::DefinedIo) const;
45   std::size_t items{0};
46   const NonTbpDefinedIo *item{nullptr};
47   // True when the only procedures to be used are the type-bound special
48   // procedures in the type information tables and any non-null procedures
49   // in this table.  When false, the entries in this table override whatever
50   // non-type-bound specific procedures might be in the type information,
51   // but the remaining specifics remain visible.
52   bool ignoreNonTbpEntries{false};
53 };
54 
55 } // namespace Fortran::runtime::io
56 #endif // FORTRAN_RUNTIME_NON_TBP_DIO_H_
57