annotate flang/docs/Semantics.md @ 248:cfe92afade2b

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 16 Aug 2023 18:23:14 +0900
parents 2e18cbf3894f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 <!--===- docs/Semantics.md
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 See https://llvm.org/LICENSE.txt for license information.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 -->
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 # Semantic Analysis
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 ```eval_rst
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 .. contents::
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 :local:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 ```
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 The semantic analysis pass determines if a syntactically correct Fortran
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 program is is legal by enforcing the constraints of the language.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 The input is a parse tree with a `Program` node at the root;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 and a "cooked" character stream, a contiguous stream of characters
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 containing a normalized form of the Fortran source.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 The semantic analysis pass takes a parse tree for a syntactically
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 correct Fortran program and determines whether it is legal by enforcing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 the constraints of the language.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 If the program is not legal, the results of the semantic pass will be a list of
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 errors associated with the program.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 If the program is legal, the semantic pass will produce a (possibly modified)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 parse tree for the semantically correct program with each name mapped to a symbol
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 and each expression fully analyzed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 All user errors are detected either prior to or during semantic analysis.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 After it completes successfully the program should compile with no error messages.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 There may still be warnings or informational messages.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 ## Phases of Semantic Analysis
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 1. [Validate labels](#validate-labels) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 Check all constraints on labels and branches
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 2. [Rewrite DO loops](#rewrite-do-loops) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 Convert all occurrences of `LabelDoStmt` to `DoConstruct`.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 3. [Name resolution](#name-resolution) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 Analyze names and declarations, build a tree of Scopes containing Symbols,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 and fill in the `Name::symbol` data member in the parse tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 4. [Rewrite parse tree](#rewrite-parse-tree) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 Fix incorrect parses based on symbol information
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 5. [Expression analysis](#expression-analysis) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 Analyze all expressions in the parse tree and fill in `Expr::typedExpr` and
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 `Variable::typedExpr` with analyzed expressions; fix incorrect parses
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 based on the result of this analysis
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 6. [Statement semantics](#statement-semantics) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 Perform remaining semantic checks on the execution parts of subprograms
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 7. [Write module files](#write-module-files) -
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 If no errors have occurred, write out `.mod` files for modules and submodules
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 If phase 1 or phase 2 encounter an error on any of the program units,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 compilation terminates. Otherwise, phases 3-6 are all performed even if
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 errors occur.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 Module files are written (phase 7) only if there are no errors.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 ### Validate labels
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Perform semantic checks related to labels and branches:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 - check that any labels that are referenced are defined and in scope
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 - check branches into loop bodies
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 - check that labeled `DO` loops are properly nested
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 - check labels in data transfer statements
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 ### Rewrite DO loops
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 This phase normalizes the parse tree by removing all unstructured `DO` loops
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 and replacing them with `DO` constructs.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 ### Name resolution
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 The name resolution phase walks the parse tree and constructs the symbol table.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 The symbol table consists of a tree of `Scope` objects rooted at the global scope.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 The global scope is owned by the `SemanticsContext` object.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 It contains a `Scope` for each program unit in the compilation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 Each `Scope` in the scope tree contains child scopes representing other scopes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 lexically nested in it.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 Each `Scope` also contains a map of `CharBlock` to `Symbol` representing names
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 declared in that scope. (All names in the symbol table are represented as
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 `CharBlock` objects, i.e. as substrings of the cooked character stream.)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 All `Symbol` objects are owned by the symbol table data structures.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 They should be accessed as `Symbol *` or `Symbol &` outside of the symbol
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 table classes as they can't be created, copied, or moved.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 The `Symbol` class has functions and data common across all symbols, and a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 `details` field that contains more information specific to that type of symbol.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 Many symbols also have types, represented by `DeclTypeSpec`.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 Types are also owned by scopes.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 Name resolution happens on the parse tree in this order:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 1. Process the specification of a program unit:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 1. Create a new scope for the unit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 2. Create a symbol for each contained subprogram containing just the name
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 3. Process the opening statement of the unit (`ModuleStmt`, `FunctionStmt`, etc.)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 4. Process the specification part of the unit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 2. Apply the same process recursively to nested subprograms
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 3. Process the execution part of the program unit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 4. Process the execution parts of nested subprograms recursively
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 After the completion of this phase, every `Name` corresponds to a `Symbol`
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 unless an error occurred.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 ### Rewrite parse tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 The parser cannot build a completely correct parse tree without symbol information.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 This phase corrects mis-parses based on symbols:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 - Array element assignments may be parsed as statement functions: `a(i) = ...`
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 - Namelist group names without `NML=` may be parsed as format expressions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 - A file unit number expression may be parsed as a character variable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 This phase also produces an internal error if it finds a `Name` that does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 have its `symbol` data member filled in. This error is suppressed if other
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 errors have occurred because in that case a `Name` corresponding to an erroneous
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 symbol may not be resolved.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 ### Expression analysis
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 Expressions that occur in the specification part are analyzed during name
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 resolution, for example, initial values, array bounds, type parameters.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 Any remaining expressions are analyzed in this phase.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 For each `Variable` and top-level `Expr` (i.e. one that is not nested below
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 another `Expr` in the parse tree) the analyzed form of the expression is saved
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 in the `typedExpr` data member. After this phase has completed, the analyzed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 expression can be accessed using `semantics::GetExpr()`.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 This phase also corrects mis-parses based on the result of expression analysis:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 - An expression like `a(b)` is parsed as a function reference but may need
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 to be rewritten to an array element reference (if `a` is an object entity)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 or to a structure constructor (if `a` is a derive type)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 - An expression like `a(b:c)` is parsed as an array section but may need to be
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 rewritten as a substring if `a` is an object with type CHARACTER
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 ### Statement semantics
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 Multiple independent checkers driven by the `SemanticsVisitor` framework
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 perform the remaining semantic checks.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 By this phase, all names and expressions that can be successfully resolved
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 have been. But there may be names without symbols or expressions without
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 analyzed form if errors occurred earlier.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 ### Initialization processing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 Fortran supports many means of specifying static initializers for variables,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 object pointers, and procedure pointers, as well as default initializers for
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 derived type object components, pointers, and type parameters.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 Non-pointer static initializers of variables and named constants are
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 scanned, analyzed, folded, scalar-expanded, and validated as they are
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 traversed during declaration processing in name resolution.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 So are the default initializers of non-pointer object components in
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 non-parameterized derived types.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 Name constant arrays with implied shapes take their actual shape from
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 the initialization expression.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 Default initializers of non-pointer components and type parameters
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 in distinct parameterized
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 derived type instantiations are similarly processed as those instances
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 are created, as their expressions may depend on the values of type
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 parameters.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 Error messages produced during parameterized derived type instantiation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 are decorated with contextual attachments that point to the declarations
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 or other type specifications that caused the instantiation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 Static initializations in `DATA` statements are collected, validated,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 and converted into static initialization in the symbol table, as if
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 the initialized objects had used the newer style of static initialization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 in their entity declarations.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 All statically initialized pointers, and default component initializers for
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 pointers, are processed late in name resolution after all specification parts
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 have been traversed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 This allows for forward references even in the presence of `IMPLICIT NONE`.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 Object pointer initializers in parameterized derived type instantiations are
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 also cloned and folded at this late stage.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 Validation of pointer initializers takes place later in declaration
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 checking (below).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 ### Declaration checking
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 Whenever possible, the enforcement of constraints and "shalls" pertaining to
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 properties of symbols is deferred to a single read-only pass over the symbol table
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 that takes place after all name resolution and typing is complete.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 ### Write module files
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 Separate compilation information is written out on successful compilation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 of modules and submodules. These are used as input to name resolution
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 in program units that `USE` the modules.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 Module files are stripped down Fortran source for the module.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 Parts that aren't needed to compile dependent program units (e.g. action statements)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 are omitted.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 The module file for module `m` is named `m.mod` and the module file for
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 submodule `s` of module `m` is named `m-s.mod`.