equal
deleted
inserted
replaced
53 tree_root->accept(enum_declaration_check); |
53 tree_root->accept(enum_declaration_check); |
54 return enum_declaration_check.get_error_count(); |
54 return enum_declaration_check.get_error_count(); |
55 } |
55 } |
56 |
56 |
57 |
57 |
|
58 /* In order to correctly handle variable sized arrays |
|
59 * declaration_safety() must only be run after constant folding! |
|
60 * NOTE that the dependency does not resides directly in declaration_check_c, |
|
61 * but rather indirectly in the call to get_datatype_info_c::is_type_equal() |
|
62 * which may in turn call get_datatype_info_c::is_arraytype_equal_relaxed() |
|
63 * |
|
64 * Example of a variable sized array: |
|
65 * VAR_EXTERN CONSTANT max: INT; END_VAR; |
|
66 * VAR_EXTERN xx: ARRAY [1..max] OF INT; END_VAR; |
|
67 */ |
58 static int declaration_safety(symbol_c *tree_root){ |
68 static int declaration_safety(symbol_c *tree_root){ |
59 declaration_check_c declaration_check(tree_root); |
69 declaration_check_c declaration_check(tree_root); |
60 tree_root->accept(declaration_check); |
70 tree_root->accept(declaration_check); |
61 return declaration_check.get_error_count(); |
71 return declaration_check.get_error_count(); |
62 } |
72 } |
136 |
146 |
137 |
147 |
138 int stage3(symbol_c *tree_root, symbol_c **ordered_tree_root) { |
148 int stage3(symbol_c *tree_root, symbol_c **ordered_tree_root) { |
139 int error_count = 0; |
149 int error_count = 0; |
140 error_count += enum_declaration_check(tree_root); |
150 error_count += enum_declaration_check(tree_root); |
141 error_count += declaration_safety(tree_root); |
|
142 error_count += flow_control_analysis(tree_root); |
151 error_count += flow_control_analysis(tree_root); |
143 error_count += constant_propagation(tree_root); |
152 error_count += constant_propagation(tree_root); |
|
153 error_count += declaration_safety(tree_root); |
144 error_count += type_safety(tree_root); |
154 error_count += type_safety(tree_root); |
145 error_count += lvalue_check(tree_root); |
155 error_count += lvalue_check(tree_root); |
146 error_count += array_range_check(tree_root); |
156 error_count += array_range_check(tree_root); |
147 error_count += remove_forward_dependencies(tree_root, ordered_tree_root); |
157 error_count += remove_forward_dependencies(tree_root, ordered_tree_root); |
148 |
158 |