Changeset 169

Show
Ignore:
Timestamp:
05/12/07 19:13:11 (2 years ago)
Author:
ant_39
Message:
  • Fixes in cloning and reparenting of statements.
  • Full second resolution now performed on call site.
  • New test for type mismatch of implicit parameter.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gcc/gcc/algol60/a60_symtab.c

    r168 r169  
    115115      type_t * symtype = symbol_type (sym); 
    116116      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))) 
    118120        break; 
    119121 
     
    190192    { 
    191193      assert (pr != NULL && it != NULL); 
     194      assert (slist_it_has (pr)); 
     195      assert (slist_it_has (it)); 
    192196      ret = slist_it_erase_after (pr); 
    193197      delete_slist_it (pr); 
     
    216220} 
    217221 
    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 
     222int 
     223a60_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; 
    222228  slist_it_t * it = slist_iter (self->table); 
    223229  for (; slist_it_has (it); slist_it_next (it)) 
     
    234240      if (found == NULL) 
    235241        { 
     242          /* 
    236243          int was_there = a60_symtab_add_symbol (context_tab, new_symbol_var (label), 
    237244                                                 sek_ordinary); 
     
    239246          found = a60_symtab_find_name (self, label, type_any ()); 
    240247          symbol_set_type (found, type_unknown ()); 
     248          */ 
    241249 
    242250          log_printfc (log, ll_error, a60_as_cursor (symbol_extra (sym)), 
     
    245253          log_printfc (log, ll_error, cursor, 
    246254                       "cannot be resolved at this point in file."); 
     255 
     256          ret = 0; 
    247257        } 
    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 
    251266  delete_slist_it (it); 
     267 
     268  return ret; 
    252269} 
    253270 
  • trunk/gcc/gcc/algol60/a60_symtab.h

    r168 r169  
    9696/// symbol in the symbol table, and adds into list `ret_list` a 
    9797/// 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. 
    100100/// 
    101101/// Only the symbols in `self` that are of type `implicit' are looked 
    102102/// 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. 
     106int a60_symtab_second_resolve_symbols (a60_symtab_t * self, slist_t * ret_list, a60_symtab_t * context_tab, logger_t * log, cursor_t * cursor) 
    104107  ATTRIBUTE_NONNULL(1) 
    105108  ATTRIBUTE_NONNULL(2) 
  • trunk/gcc/gcc/algol60/expression.c

    r168 r169  
    659659  // is `implicit`, it is yet to be resolved, and also don't report. 
    660660  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)) 
    662662    { 
    663663      type_t * tt = expr_type (self); 
     
    772772      a60_symtab_t * f_implicit = container_symtab (f_container); 
    773773      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); 
    776792    } 
    777793} 
  • trunk/gcc/gcc/algol60/statement.c

    r168 r169  
    228228  if (types_same (symbol_type (sym), type_label ())) 
    229229    slist_pushback (labels, sym); 
     230  return NULL; 
    230231} 
    231232 
     
    726727{ 
    727728  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; 
    729733} 
    730734 
     
    749753 
    750754  slist_pushback (self->block.statements, stmt); 
    751   stmt->parent = _self
     755  stmt_set_parent (stmt, _self)
    752756} 
    753757 
  • trunk/gcc/gcc/algol60/type.h

    r165 r169  
    160160  ATTRIBUTE_NONNULL (1); 
    161161 
    162 /// Answers 1 or 0, depending on whether the two types are the same. 
     162/// Answers 1 or 0, depending on whether the two types are same. 
    163163/// Array bounds are not taken into account. 
    164164/// Switchlist of switch type is not taken into account. 
  • trunk/gcc/gcc/testsuite/algol60.dg/compile/fun1.a60

    r160 r169  
    33        'procedure' foo1; 
    44        'begin' 
    5                 puts (`yay!'); 
     5                puts (`yay!'); 'comment' { dg-warning "implicit" } ; 
    66        'end'; 
    77 
     
    1111        'real' c; 
    1212        'begin' 
    13                 puts (`yay!'); 
     13                puts (`yay!'); 'comment' { dg-warning "implicit" } ; 
    1414        'end'; 
    1515 
     
    1717        'integer' a; 
    1818        'begin' 
    19                 puts (`yay!'); 
     19                puts (`yay!'); 'comment' { dg-warning "implicit" } ; 
    2020        'end'; 
    2121 
     
    2424        'integer' a; 
    2525        'begin' 
    26                 puts (`yay!'); 
     26                puts (`yay!'); 'comment' { dg-warning "implicit" } ; 
    2727        'end'; 
    2828'end';