idf.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Header$ */
  6. /* IDENTIFIER FIDDLING & SYMBOL TABLE HANDLING */
  7. #include "lint.h"
  8. #include <em_reg.h>
  9. #include "debug.h"
  10. #include "idfsize.h"
  11. #include "botch_free.h"
  12. #include "nopp.h"
  13. #include "nparams.h"
  14. #include <alloc.h>
  15. #include "arith.h"
  16. #include "align.h"
  17. #include "LLlex.h"
  18. #include "level.h"
  19. #include "stack.h"
  20. #include "idf.h"
  21. #include "label.h"
  22. #include "def.h"
  23. #include "type.h"
  24. #include "proto.h"
  25. #include "struct.h"
  26. #include "declar.h"
  27. #include "decspecs.h"
  28. #include "sizes.h"
  29. #include "Lpars.h"
  30. #include "assert.h"
  31. #include "specials.h" /* registration of special identifiers */
  32. int idfsize = IDFSIZE;
  33. extern char options[];
  34. extern arith NewLocal();
  35. extern char *symbol2str();
  36. char sp_occurred[SP_TOTAL+1]; /* indicate occurrence of special id */
  37. struct idf *idf_hashtable[HASHSIZE];
  38. /* All identifiers can in principle be reached through
  39. idf_hashtable; idf_hashtable[hc] is the start of a chain of
  40. idf's whose tags all hash to hc. Each idf is the start of
  41. a chain of def's for that idf, sorted according to level,
  42. with the most recent one on top.
  43. Any identifier occurring on a level is entered into this
  44. list, regardless of the nature of its declaration
  45. (variable, selector, structure tag, etc.).
  46. */
  47. struct idf *
  48. idf_hashed(tg, size, hc)
  49. char *tg;
  50. int size; /* includes the '\0' character */
  51. int hc;
  52. {
  53. /* The tag tg with length size and known hash value hc is
  54. looked up in the identifier table; if not found, it is
  55. entered. A pointer to it is returned.
  56. The identifier has already been truncated to idfsize
  57. characters.
  58. */
  59. register struct idf **hook = &idf_hashtable[hc], *notch;
  60. while ((notch = *hook)) {
  61. register char *s1 = tg;
  62. register char *cp = notch->id_text;
  63. register int cmp;
  64. while (!(cmp = (*s1 - *cp++))) {
  65. if (*s1++ == '\0') {
  66. break;
  67. }
  68. }
  69. if (cmp < 0)
  70. break;
  71. if (cmp == 0) {
  72. /* suppose that special identifiers, as
  73. "__setjmp", are already inserted
  74. */
  75. sp_occurred[notch->id_special] = 1;
  76. return notch;
  77. }
  78. hook = &notch->next;
  79. }
  80. /* a new struct idf must be inserted at the hook */
  81. notch = new_idf();
  82. notch->next = *hook;
  83. *hook = notch; /* hooked in */
  84. notch->id_text = Salloc(tg, (unsigned) size);
  85. #ifndef NOPP
  86. /* notch->id_resmac = 0; */
  87. #endif NOPP
  88. return notch;
  89. }
  90. #ifdef DEBUG
  91. hash_stat()
  92. {
  93. if (options['h']) {
  94. register int i;
  95. print("Hash table tally:\n");
  96. for (i = 0; i < HASHSIZE; i++) {
  97. register struct idf *notch = idf_hashtable[i];
  98. int cnt = 0;
  99. while (notch) {
  100. cnt++;
  101. notch = notch->next;
  102. }
  103. print("%d %d\n", i, cnt);
  104. }
  105. print("End hash table tally\n");
  106. }
  107. }
  108. #endif DEBUG
  109. struct idf *
  110. str2idf(tg)
  111. char tg[];
  112. {
  113. /* str2idf() returns an entry in the symbol table for the
  114. identifier tg. If necessary, an entry is created.
  115. It is used where the text of the identifier is available
  116. but its hash value is not; otherwise idf_hashed() is to
  117. be used.
  118. */
  119. register char *cp = tg;
  120. register int hash;
  121. register int pos = -1;
  122. register int ch;
  123. char ntg[IDFSIZE + 1];
  124. register char *ncp = ntg;
  125. hash = STARTHASH();
  126. while (++pos < idfsize && (ch = *cp++)) {
  127. *ncp++ = ch;
  128. hash = ENHASH(hash, ch);
  129. }
  130. hash = STOPHASH(hash);
  131. *ncp++ = '\0';
  132. return idf_hashed(ntg, (int) (ncp - ntg), hash);
  133. }
  134. struct idf *
  135. gen_idf()
  136. {
  137. /* A new idf is created out of nowhere, to serve as an
  138. anonymous name.
  139. */
  140. static int name_cnt;
  141. char buff[100];
  142. sprint(buff, "#%d in %s, line %u",
  143. ++name_cnt, dot.tk_file, dot.tk_line);
  144. return str2idf(buff);
  145. }
  146. int
  147. is_anon_idf(idf)
  148. struct idf *idf;
  149. {
  150. return idf->id_text[0] == '#';
  151. }
  152. declare_idf(ds, dc, lvl)
  153. struct decspecs *ds;
  154. struct declarator *dc;
  155. {
  156. /* The identifier inside dc is declared on the level lvl, with
  157. properties deduced from the decspecs ds and the declarator
  158. dc.
  159. The level is given explicitly to be able to insert, e.g.,
  160. labels on the outermost level inside the function.
  161. This routine implements the rich semantics of C
  162. declarations.
  163. */
  164. register struct idf *idf = dc->dc_idf;
  165. register int sc = ds->ds_sc;
  166. /* This local copy is essential:
  167. char b(), c;
  168. makes b GLOBAL and c AUTO.
  169. */
  170. register struct def *def = idf->id_def; /* may be NULL */
  171. register struct type *type;
  172. struct stack_level *stl = stack_level_of(lvl);
  173. char formal_array = 0;
  174. /* determine the present type */
  175. if (ds->ds_type == 0) {
  176. /* at the L_FORMAL1 level there is no type specified yet
  177. */
  178. ASSERT(lvl == L_FORMAL1);
  179. type = int_type; /* may change at L_FORMAL2 */
  180. }
  181. else {
  182. /* combine the decspecs and the declarator into one type */
  183. type = declare_type(ds->ds_type, dc);
  184. if (type->tp_size <= (arith)0 &&
  185. actual_declaration(sc, type)) {
  186. if (type->tp_size == (arith) -1) {
  187. /* the type is not yet known,
  188. but it has to be:
  189. */
  190. if (type->tp_fund != VOID) {
  191. if (level != L_GLOBAL)
  192. error("unknown %s-type",
  193. symbol2str(type->tp_fund));
  194. } else error("void is not a complete type");
  195. }
  196. else if (type->tp_fund != LABEL) {
  197. /* CJ */
  198. strict("%s has size 0", idf->id_text);
  199. }
  200. }
  201. }
  202. /* some additional work for formal definitions */
  203. if (lvl == L_FORMAL2) {
  204. switch (type->tp_fund) {
  205. case FUNCTION:
  206. warning("%s is a function; cannot be formal",
  207. idf->id_text);
  208. type = construct_type(POINTER, type, 0, (arith)0,
  209. NO_PROTO);
  210. break;
  211. case ARRAY: /* 3.7.1 */
  212. type = construct_type(POINTER, type->tp_up, 0, (arith)0,
  213. NO_PROTO);
  214. formal_array = 1;
  215. break;
  216. case FLOAT:
  217. case CHAR:
  218. case SHORT:
  219. /* The conversion is done in formal_cvt(). It is
  220. * not done when the type is float and there is a
  221. * prototype.
  222. */
  223. break;
  224. }
  225. }
  226. /* The tests on types, postponed from do_decspecs(), can now
  227. be performed.
  228. */
  229. /* update the storage class */
  230. if (type && type->tp_fund == FUNCTION) {
  231. if (lvl != L_GLOBAL) { /* 3.5.1 */
  232. if (sc == 0)
  233. sc = GLOBAL;
  234. else if (sc != EXTERN && sc != TYPEDEF) {
  235. error("illegal storage class %s for function with block-scope"
  236. , symbol2str(sc));
  237. ds->ds_sc = sc = EXTERN;
  238. }
  239. }
  240. else if (sc == 0)
  241. sc = GLOBAL;
  242. }
  243. else /* non-FUNCTION */
  244. if (sc == 0)
  245. sc = lvl == L_GLOBAL ? GLOBAL
  246. : lvl == L_FORMAL1 || lvl == L_FORMAL2 ? FORMAL
  247. : AUTO;
  248. #ifdef LINT
  249. if ( def && def->df_level < lvl
  250. && !( lvl == L_FORMAL2
  251. || def->df_level == L_UNIVERSAL
  252. || sc == GLOBAL
  253. || sc == EXTERN
  254. )
  255. ) {
  256. /* there is already a definition for this non-extern name
  257. on a more global level
  258. */
  259. warning("%s is already defined as a %s",
  260. idf->id_text,
  261. def->df_level == L_GLOBAL ? "global" :
  262. def->df_level == L_FORMAL2 ? "formal" :
  263. "more global local"
  264. );
  265. }
  266. #endif LINT
  267. if ((def &&
  268. ( def->df_level == lvl ||
  269. ( lvl != L_GLOBAL && def->df_level > lvl )
  270. ))
  271. || (lvl == L_GLOBAL
  272. && def && def->df_level == L_PROTO
  273. && def->next && def->next->df_level == L_GLOBAL)
  274. ) {
  275. /* There is already a declaration for idf on this
  276. level, or even more inside.
  277. The rules differ for different levels.
  278. */
  279. switch (lvl) {
  280. case L_GLOBAL:
  281. global_redecl(idf, sc, type);
  282. def->df_file = idf->id_file;
  283. def->df_line = idf->id_line;
  284. break;
  285. case L_FORMAL1: /* formal declaration */
  286. error("formal %s redeclared", idf->id_text);
  287. break;
  288. case L_FORMAL2: /* formal definition */
  289. default: /* local */
  290. error("%s redeclared", idf->id_text);
  291. break;
  292. }
  293. }
  294. else /* the idf is unknown on this level */
  295. if (lvl == L_FORMAL2 && sc != ENUM && good_formal(def, idf)) {
  296. /* formal declaration, update only */
  297. def->df_type = type;
  298. def->df_formal_array = formal_array;
  299. def->df_sc = sc;
  300. def->df_level = L_FORMAL2; /* CJ */
  301. def->df_file = idf->id_file;
  302. def->df_line = idf->id_line;
  303. }
  304. else { /* fill in the def block */
  305. register struct def *newdef = new_def();
  306. newdef->next = def;
  307. newdef->df_level = lvl;
  308. newdef->df_type = type;
  309. newdef->df_sc = sc;
  310. newdef->df_file = idf->id_file;
  311. newdef->df_line = idf->id_line;
  312. #ifdef LINT
  313. newdef->df_set = (type->tp_fund == ARRAY);
  314. /* newdef->df_firstbrace = 0; */
  315. #endif LINT
  316. /* link it into the name list in the proper place */
  317. idf->id_def = newdef;
  318. update_ahead(idf);
  319. stack_idf(idf, stl);
  320. /* We now calculate the address.
  321. Globals have names and don't get addresses, they
  322. get numbers instead (through data_label()).
  323. Formals are handled by declare_formals().
  324. So here we hand out local addresses only.
  325. */
  326. if (lvl >= L_LOCAL) {
  327. ASSERT(sc);
  328. switch (sc) {
  329. case REGISTER:
  330. case AUTO:
  331. if (type->tp_size == (arith)-1
  332. && type->tp_fund != ARRAY) {
  333. error("size of local %s unknown",
  334. idf->id_text);
  335. /** type = idf->id_def->df_type = int_type; **/
  336. }
  337. newdef->df_address =
  338. NewLocal(type->tp_size,
  339. type->tp_align,
  340. regtype(type),
  341. sc);
  342. break;
  343. case STATIC:
  344. newdef->df_address = (arith) data_label();
  345. break;
  346. }
  347. }
  348. }
  349. }
  350. actual_declaration(sc, tp)
  351. int sc;
  352. struct type *tp;
  353. {
  354. /* An actual_declaration needs space, right here and now.
  355. */
  356. register int fund = tp->tp_fund;
  357. if (sc == ENUM || sc == TYPEDEF) /* virtual declarations */
  358. return 0;
  359. if (fund == FUNCTION || fund == ARRAY)
  360. /* allocation solved in other ways */
  361. return 0;
  362. /* to be allocated */
  363. return 1;
  364. }
  365. global_redecl(idf, new_sc, tp)
  366. register struct idf *idf;
  367. struct type *tp;
  368. {
  369. /* A global identifier may be declared several times,
  370. provided the declarations do not conflict; they might
  371. conflict in type (or supplement each other in the case of
  372. an array) or they might conflict or supplement each other
  373. in storage class.
  374. */
  375. register struct def *def = idf->id_def;
  376. while (def->df_level != L_GLOBAL) def = def->next;
  377. if (!equal_type(tp, def->df_type, 0)) {
  378. error("redeclaration of %s with different type", idf->id_text);
  379. return;
  380. } else update_proto(tp, def->df_type);
  381. if (tp->tp_fund == ARRAY) {
  382. /* Multiple array declaration; this may be interesting */
  383. if (tp->tp_size < 0) { /* new decl has [] */
  384. /* nothing new */
  385. } else
  386. if (def->df_type->tp_size < 0) { /* old decl has [] */
  387. def->df_type = tp;
  388. }
  389. } if (tp->tp_fund == FUNCTION && new_sc == GLOBAL) {
  390. /* see 3.1.2.2 */
  391. new_sc = EXTERN;
  392. }
  393. /* Now we may be able to update the storage class.
  394. Clean out this mess as soon as we know all the possibilities
  395. for new_sc.
  396. For now we have:
  397. EXTERN: we have seen the word "extern"
  398. GLOBAL: the item was declared on the outer
  399. level, without either "extern" or
  400. "static".
  401. STATIC: we have seen the word "static"
  402. */
  403. switch (def->df_sc) { /* the old storage class */
  404. case EXTERN:
  405. switch (new_sc) { /* the new storage class */
  406. case STATIC:
  407. warning("%s redeclared static", idf->id_text);
  408. /* fallthrough */
  409. case GLOBAL:
  410. def->df_sc = new_sc;
  411. /* fallthrough */
  412. case EXTERN:
  413. break;
  414. default:
  415. crash("bad storage class");
  416. /*NOTREACHED*/
  417. }
  418. break;
  419. case GLOBAL:
  420. switch (new_sc) { /* the new storage class */
  421. case STATIC: /* linkage disagreement */
  422. warning("%s redeclared static", idf->id_text);
  423. def->df_sc = new_sc;
  424. /* fallthrough */
  425. case GLOBAL:
  426. case EXTERN:
  427. break;
  428. default:
  429. crash("bad storage class");
  430. /*NOTREACHED*/
  431. }
  432. break;
  433. case STATIC:
  434. switch (new_sc) { /* the new storage class */
  435. case GLOBAL: /* linkage disagreement */
  436. case EXTERN:
  437. warning("%s is already declared static", idf->id_text);
  438. /* fallthrough */
  439. case STATIC:
  440. break;
  441. default:
  442. crash("bad storage class");
  443. /*NOTREACHED*/
  444. }
  445. break;
  446. case ENUM:
  447. case TYPEDEF:
  448. error("illegal redeclaration of %s", idf->id_text);
  449. break;
  450. default:
  451. crash("bad storage class");
  452. /*NOTREACHED*/
  453. }
  454. }
  455. int
  456. good_formal(def, idf)
  457. register struct def *def;
  458. register struct idf *idf;
  459. {
  460. /* Succeeds if def is a proper L_FORMAL1 definition and
  461. gives an error message otherwise.
  462. */
  463. if (!def || def->df_level != L_FORMAL1) { /* not in parameter list */
  464. if (!is_anon_idf(idf))
  465. error("%s not in parameter list", idf->id_text);
  466. return 0;
  467. }
  468. ASSERT(def->df_sc == FORMAL); /* CJ */
  469. return 1;
  470. }
  471. declare_params(dc)
  472. struct declarator *dc;
  473. {
  474. /* Declares the formal parameters if they exist.
  475. */
  476. register struct formal *fm = dc->dc_formal;
  477. while (fm) {
  478. declare_parameter(fm->fm_idf);
  479. fm = fm->next;
  480. }
  481. }
  482. init_idf(idf)
  483. register struct idf *idf;
  484. {
  485. /* The topmost definition of idf is set to initialized.
  486. */
  487. register struct def *def = idf->id_def; /* the topmost */
  488. while (def->df_level <= L_PROTO) def = def->next;
  489. if (def->df_initialized)
  490. error("multiple initialization of %s", idf->id_text);
  491. if (def->df_sc == TYPEDEF) {
  492. error("typedef cannot be initialized");
  493. return;
  494. }
  495. def->df_initialized = 1;
  496. }
  497. declare_parameter(idf)
  498. struct idf *idf;
  499. {
  500. /* idf is declared as a formal.
  501. */
  502. add_def(idf, FORMAL, int_type, level);
  503. }
  504. declare_enum(tp, idf, l)
  505. struct type *tp;
  506. struct idf *idf;
  507. arith l;
  508. {
  509. /* idf is declared as an enum constant with value l.
  510. */
  511. add_def(idf, ENUM, tp, level);
  512. idf->id_def->df_address = l;
  513. }
  514. check_formals(idf, dc)
  515. struct idf *idf;
  516. struct declarator *dc;
  517. {
  518. register struct formal *fm = dc->dc_formal;
  519. register struct proto *pl = idf->id_def->df_type->tp_proto;
  520. register struct decl_unary *du = dc->dc_decl_unary;
  521. if (!du) { /* error or typdef'ed function */
  522. error("illegal definition of %s", idf->id_text);
  523. return;
  524. }
  525. while (du && du->du_fund != FUNCTION)
  526. du = du->next;
  527. if (!du) return; /* terrible error, signalled earlier */
  528. if (du->du_proto) return;
  529. if (pl) {
  530. /* Don't give a warning about an old-style definition,
  531. * since the arguments will be checked anyway.
  532. */
  533. if (pl->pl_flag & PL_ELLIPSIS) {
  534. if (!(du->du_proto) && !(pl->pl_flag & PL_ERRGIVEN))
  535. error("ellipsis terminator in previous declaration");
  536. pl = pl->next;
  537. }
  538. else if (pl->pl_flag & PL_VOID) {
  539. pl = pl->next; /* should be 0 */
  540. }
  541. while(fm && pl) {
  542. if (!equal_type(promoted_type(fm->fm_idf->id_def->df_type)
  543. , pl->pl_type, -1)) {
  544. if (!(pl->pl_flag & PL_ERRGIVEN))
  545. error("incorrect type for parameter %s"
  546. , fm->fm_idf->id_text);
  547. pl->pl_flag |= PL_ERRGIVEN;
  548. }
  549. fm = fm->next;
  550. pl = pl->next;
  551. }
  552. if (pl || fm) {
  553. error("incorrect number of parameters");
  554. }
  555. } else { /* make a pseudo-prototype */
  556. register struct proto *lpl = new_proto();
  557. if (!options['o'])
  558. warning("'%s' old-fashioned function definition"
  559. , dc->dc_idf->id_text);
  560. while (fm) {
  561. if (pl == 0) pl = lpl;
  562. else {
  563. lpl->next = new_proto();
  564. lpl = lpl->next;
  565. }
  566. lpl->pl_flag = PL_FORMAL;
  567. lpl->pl_idf = fm->fm_idf;
  568. lpl->pl_type =
  569. promoted_type(fm->fm_idf->id_def->df_type);
  570. fm = fm->next;
  571. }
  572. if (pl == 0) { /* make func(void) */
  573. pl = lpl;
  574. pl->pl_type = void_type;
  575. pl->pl_flag = PL_FORMAL | PL_VOID;
  576. }
  577. idf->id_def->df_type->tp_pseudoproto = pl;
  578. }
  579. free_formals(dc->dc_formal);
  580. dc->dc_formal = 0;
  581. }
  582. declare_formals(idf, fp)
  583. struct idf *idf;
  584. arith *fp;
  585. {
  586. /* Declares those formals as int that haven't been declared
  587. by the user.
  588. An address is assigned to each formal parameter.
  589. The total size of the formals is returned in *fp;
  590. */
  591. register struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
  592. arith f_offset = (arith)0;
  593. register int nparams = 0;
  594. int hasproto = idf->id_def->df_type->tp_proto != 0;
  595. #ifdef DEBUG
  596. if (options['t'])
  597. dumpidftab("start declare_formals", 0);
  598. #endif DEBUG
  599. while (se) {
  600. register struct def *def = se->se_idf->id_def;
  601. /* this stacklevel may also contain tags. ignore them */
  602. if (!def || def->df_level < L_FORMAL1 ) {
  603. se = se->next;
  604. continue;
  605. }
  606. def->df_address = f_offset;
  607. /* the alignment convention for parameters is: align on
  608. word boundaries, i.e. take care that the following
  609. parameter starts on a new word boundary.
  610. */
  611. f_offset = align(f_offset + def->df_type->tp_size, (int) word_size);
  612. /* cvt int to char or short and double to float, if necessary
  613. */
  614. formal_cvt(hasproto, def);
  615. def->df_level = L_FORMAL2; /* CJ */
  616. RegisterAccount(def->df_address, def->df_type->tp_size,
  617. regtype(def->df_type),
  618. def->df_sc);
  619. if (nparams++ >= STDC_NPARAMS)
  620. strict("number of formal parameters exceeds ANSI limit");
  621. #ifdef DBSYMTAB
  622. if (options['g']) {
  623. stb_string(def, FORMAL, se->se_idf->id_text);
  624. }
  625. #endif /* DBSYMTAB */
  626. se = se->next;
  627. }
  628. *fp = f_offset;
  629. }
  630. int
  631. regtype(tp)
  632. struct type *tp;
  633. {
  634. switch(tp->tp_fund) {
  635. case INT:
  636. case LONG:
  637. return reg_any;
  638. case FLOAT:
  639. case DOUBLE:
  640. case LNGDBL:
  641. return reg_float;
  642. case POINTER:
  643. return reg_pointer;
  644. }
  645. return -1;
  646. }
  647. add_def(idf, sc, tp, lvl)
  648. struct idf *idf;
  649. struct type *tp;
  650. int lvl;
  651. int sc;
  652. {
  653. /* The identifier idf is declared on level lvl with storage
  654. class sc and type tp, through a faked C declaration.
  655. This is probably the wrong way to structure the problem,
  656. but it will have to do for the time being.
  657. */
  658. struct decspecs Ds; struct declarator Dc;
  659. Ds = null_decspecs;
  660. Ds.ds_type = tp;
  661. Ds.ds_sc = sc;
  662. Dc = null_declarator;
  663. Dc.dc_idf = idf;
  664. declare_idf(&Ds, &Dc, lvl);
  665. }
  666. update_ahead(idf)
  667. register struct idf *idf;
  668. {
  669. /* The tk_symb of the token ahead is updated in the light of new
  670. information about the identifier idf.
  671. */
  672. register int tk_symb = AHEAD;
  673. if ( (tk_symb == IDENTIFIER || tk_symb == TYPE_IDENTIFIER) &&
  674. ahead.tk_idf == idf
  675. )
  676. AHEAD = idf->id_def && idf->id_def->df_sc == TYPEDEF ?
  677. TYPE_IDENTIFIER : IDENTIFIER;
  678. }
  679. free_formals(fm)
  680. register struct formal *fm;
  681. {
  682. while (fm) {
  683. struct formal *tmp = fm->next;
  684. free_formal(fm);
  685. fm = tmp;
  686. }
  687. }