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: declarator.c,v 1.8 1994/06/27 07:59:09 ceriel Exp $ */
6 /* D E C L A R A T O R M A N I P U L A T I O N */
9 #include "botch_free.h"
11 #include <flt_arith.h>
24 extern char options[];
25 struct declarator null_declarator;
30 struct declarator *dc;
32 /* Applies the decl_unary list starting at dc->dc_decl_unary
33 to the type tp and returns the result.
34 Functions that are declared within a parameter type list
35 are purely prototypes. Simply add the type list to the
38 register struct decl_unary *du = dc->dc_decl_unary;
41 tp = construct_type(du->du_fund, tp, du->du_typequal,
42 du->du_count, du->du_proto);
48 add_decl_unary(dc, fund, qual, count, fm, pl)
49 register struct declarator *dc;
55 /* A decl_unary describing a constructor with fundamental
56 type fund and with size count is inserted in front of the
59 register struct decl_unary *new = new_decl_unary();
61 new->next = dc->dc_decl_unary;
63 new->du_count = count;
64 new->du_typequal = qual;
67 if (dc->dc_decl_unary) {
68 /* parameters only allowed at first decl_unary */
69 error("formal parameters list discarded");
72 /* register the proto */
77 dc->dc_decl_unary = new;
81 struct declarator *dc;
83 /* The decl_unary list starting at dc->dc_decl_unary is
86 register struct decl_unary *du = dc->dc_decl_unary;
89 struct decl_unary *old_du = du;
92 free_decl_unary(old_du);
97 register struct declarator *dc;
99 /* The declarator is checked to have no parameters, if it
100 is an old-style function. If it is a new-style function,
101 the identifiers are removed. The function is not called in
102 case of a function definition.
104 register struct decl_unary *du = dc->dc_decl_unary;
108 error("non_empty formal parameter pack");
109 free_formals(dc->dc_formal);
114 if (du->du_fund == FUNCTION) {
115 if (du->du_proto) remove_proto_idfs(du->du_proto);
116 else if (! err_given && ! options['o']) {
118 warning("old-fashioned function declaration");
125 check_array_subscript(expr)
126 register struct expr *expr;
128 arith size = expr->VL_VALUE;
131 error("array size is negative");
132 expr->VL_VALUE = (arith)1;
136 strict("array size is 0");
139 if (size & ~max_unsigned) { /* absolutely ridiculous */
140 expr_error(expr, "overflow in array size");
141 expr->VL_VALUE = (arith)1;