Changeset 169
- Timestamp:
- 05/12/07 19:13:11 (2 years ago)
- Files:
-
- trunk/gcc/gcc/algol60/a60_symtab.c (modified) (6 diffs)
- trunk/gcc/gcc/algol60/a60_symtab.h (modified) (1 diff)
- trunk/gcc/gcc/algol60/expression.c (modified) (2 diffs)
- trunk/gcc/gcc/algol60/statement.c (modified) (3 diffs)
- trunk/gcc/gcc/algol60/type.h (modified) (1 diff)
- trunk/gcc/gcc/testsuite/algol60.dg/compile/fun1.a60 (modified) (4 diffs)
- trunk/gcc/gcc/testsuite/algol60.dg/fail/fun2.a60 (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gcc/gcc/algol60/a60_symtab.c
r168 r169 115 115 type_t * symtype = symbol_type (sym); 116 116 if (label_eq (symbol_label (sym), lbl) 117 && (symtype == NULL || types_match (symtype, atype))) 117 && (symtype == NULL 118 || types_same (symtype, atype) 119 || types_match (symtype, atype))) 118 120 break; 119 121 … … 190 192 { 191 193 assert (pr != NULL && it != NULL); 194 assert (slist_it_has (pr)); 195 assert (slist_it_has (it)); 192 196 ret = slist_it_erase_after (pr); 193 197 delete_slist_it (pr); … … 216 220 } 217 221 218 void 219 a60_symtab_second_lookup (a60_symtab_t * self, slist_t * ret_list, a60_symtab_t * context_tab, 220 logger_t * log, cursor_t * cursor) 221 { 222 int 223 a60_symtab_second_resolve_symbols (a60_symtab_t * self, slist_t * ret_list, 224 a60_symtab_t * context_tab, 225 logger_t * log, cursor_t * cursor) 226 { 227 int ret = 1; 222 228 slist_it_t * it = slist_iter (self->table); 223 229 for (; slist_it_has (it); slist_it_next (it)) … … 234 240 if (found == NULL) 235 241 { 242 /* 236 243 int was_there = a60_symtab_add_symbol (context_tab, new_symbol_var (label), 237 244 sek_ordinary); … … 239 246 found = a60_symtab_find_name (self, label, type_any ()); 240 247 symbol_set_type (found, type_unknown ()); 248 */ 241 249 242 250 log_printfc (log, ll_error, a60_as_cursor (symbol_extra (sym)), … … 245 253 log_printfc (log, ll_error, cursor, 246 254 "cannot be resolved at this point in file."); 255 256 ret = 0; 247 257 } 248 249 slist_pushback (ret_list, found); 250 } 258 else 259 slist_pushback (ret_list, sym /*found*/); 260 } 261 262 slist_it_reset (it, ret_list); 263 for (; slist_it_has (it); slist_it_next (it)) 264 a60_symtab_erase_symbol (self, a60_as_symbol (slist_it_get (it))); 265 251 266 delete_slist_it (it); 267 268 return ret; 252 269 } 253 270 trunk/gcc/gcc/algol60/a60_symtab.h
r168 r169 96 96 /// symbol in the symbol table, and adds into list `ret_list` a 97 97 /// symbols found by recursive lookup in `context_tab`. The symbtab 98 /// `self` will be a symbol table with implicit parameters,99 /// `context_tab` will be symtab of call site.98 /// `self` will be function's symbol table with implicit and explicit 99 /// parameters; `context_tab` will be symtab of call site. 100 100 /// 101 101 /// Only the symbols in `self` that are of type `implicit' are looked 102 102 /// up this way. 103 void a60_symtab_second_lookup (a60_symtab_t * self, slist_t * ret_list, a60_symtab_t * context_tab, logger_t * log, cursor_t * cursor) 103 /// 104 /// The function returns 1 if all symbols were resolved, or 0 if there 105 /// were resolution errors. 106 int a60_symtab_second_resolve_symbols (a60_symtab_t * self, slist_t * ret_list, a60_symtab_t * context_tab, logger_t * log, cursor_t * cursor) 104 107 ATTRIBUTE_NONNULL(1) 105 108 ATTRIBUTE_NONNULL(2) trunk/gcc/gcc/algol60/expression.c
r168 r169 659 659 // is `implicit`, it is yet to be resolved, and also don't report. 660 660 if (!type_is_unknown (lt) && !type_is_unknown (rt) 661 && !type_is_implicit (lt) && !type_is_implicit ( lt))661 && !type_is_implicit (lt) && !type_is_implicit (rt)) 662 662 { 663 663 type_t * tt = expr_type (self); … … 772 772 a60_symtab_t * f_implicit = container_symtab (f_container); 773 773 slist_t * resolved = new_slist (); 774 a60_symtab_second_lookup (f_implicit, resolved, symtab, 775 log, expr_cursor (self)); 774 int e_messages = log_count_messages (log, ll_error); 775 int w_messages = log_count_messages (log, ll_warning); 776 if (a60_symtab_second_resolve_symbols (f_implicit, resolved, symtab, 777 log, expr_cursor (self))) 778 { 779 assert (container_parent (f_container) == NULL); 780 container_set_parent (f_container, block); 781 stmt_resolve_symbols (f_stmt, log); 782 783 debug_level_t level = ll_debug; 784 if (log_count_messages (log, ll_error) > e_messages) 785 level = ll_error; 786 else if (log_count_messages (log, ll_warning) > w_messages) 787 level = ll_warning; 788 if (level != ll_debug) 789 log_printfc (log, level, self->cursor, "at this point in file."); 790 } 791 delete_slist (resolved); 776 792 } 777 793 } trunk/gcc/gcc/algol60/statement.c
r168 r169 228 228 if (types_same (symbol_type (sym), type_label ())) 229 229 slist_pushback (labels, sym); 230 return NULL; 230 231 } 231 232 … … 726 727 { 727 728 assert (self != NULL); 728 self->parent = parent; 729 if (self->base.kind == sk_block || self->base.kind == sk_toplev) 730 container_set_parent ((container_t *)self, parent); 731 else 732 self->parent = parent; 729 733 } 730 734 … … 749 753 750 754 slist_pushback (self->block.statements, stmt); 751 stmt ->parent = _self;755 stmt_set_parent (stmt, _self); 752 756 } 753 757 trunk/gcc/gcc/algol60/type.h
r165 r169 160 160 ATTRIBUTE_NONNULL (1); 161 161 162 /// Answers 1 or 0, depending on whether the two types are thesame.162 /// Answers 1 or 0, depending on whether the two types are same. 163 163 /// Array bounds are not taken into account. 164 164 /// Switchlist of switch type is not taken into account. trunk/gcc/gcc/testsuite/algol60.dg/compile/fun1.a60
r160 r169 3 3 'procedure' foo1; 4 4 'begin' 5 puts (`yay!'); 5 puts (`yay!'); 'comment' { dg-warning "implicit" } ; 6 6 'end'; 7 7 … … 11 11 'real' c; 12 12 'begin' 13 puts (`yay!'); 13 puts (`yay!'); 'comment' { dg-warning "implicit" } ; 14 14 'end'; 15 15 … … 17 17 'integer' a; 18 18 'begin' 19 puts (`yay!'); 19 puts (`yay!'); 'comment' { dg-warning "implicit" } ; 20 20 'end'; 21 21 … … 24 24 'integer' a; 25 25 'begin' 26 puts (`yay!'); 26 puts (`yay!'); 'comment' { dg-warning "implicit" } ; 27 27 'end'; 28 28 'end';
