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".
5 /* $Id: label.c,v 3.4 1994/06/24 12:05:05 ceriel Exp $ */
6 /* L A B E L H A N D L I N G */
15 #include "noRoption.h"
17 extern char options[];
19 enter_label(idf, defining)
20 register struct idf *idf;
22 /* The identifier idf is entered as a label. If it is new,
23 it is entered into the idf list with the largest possible
24 scope, i.e., on the lowest possible level.
25 If defining, the label comes from a label statement.
28 register struct def *def = idf->id_def;
30 if (def->df_sc == LABEL) {
31 if (defining && def->df_initialized)
32 error("redeclaration of label %s",
35 else { /* there may still be room for it */
37 if (options['R'] && def->df_sc == TYPEDEF)
38 warning("label %s is also a typedef",
42 if (def->df_level == level) /* but alas, no */
43 error("%s is not a label", idf->id_text);
45 register int lvl = def->df_level + 1;
48 if (options['R'] && def->df_level > L_LOCAL)
49 warning("label %s is not function-wide",
54 add_def(idf, LABEL, label_type, lvl);
59 add_def(idf, LABEL, label_type, L_LOCAL);
61 if (idf->id_def->df_address == 0)
62 idf->id_def->df_address = (arith) text_label();
64 idf->id_def->df_initialized = 1;
68 register struct idf *idf;
70 /* The scope in which the label idf occurred is left.
72 if (!idf->id_def->df_initialized && !is_anon_idf(idf))
73 error("label %s not defined", idf->id_text);