new copyright; att/bsd/shared
[unix-history] / usr / src / usr.bin / f77 / pass1.vax / error.c
CommitLineData
dc5f2268
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
099b7138
KM
6 */
7
8#ifndef lint
dc5f2268
KB
9static char sccsid[] = "@(#)error.c 5.2 (Berkeley) %G%";
10#endif /* not lint */
099b7138
KM
11
12/*
13 * error.c
14 *
15 * Error handling routines for f77 compiler pass 1, 4.2 BSD.
16 *
17 * University of Utah CS Dept modification history:
18 *
19 * Revision 1.2 84/08/20 17:57:20 donn
20 * Added strategic colons to the format strings in execerr() and dclerr().
21 *
22 */
23
24#include "defs.h"
25
26
27warn1(s,t)
28char *s, *t;
29{
30char buff[100];
31sprintf(buff, s, t);
32warn(buff);
33}
34
35
36warn(s)
37char *s;
38{
39if(nowarnflag)
40 return;
41fprintf(diagfile, "Warning on line %d of %s: %s\n", lineno, infname, s);
42++nwarn;
43}
44
45
46errstr(s, t)
47char *s, *t;
48{
49char buff[100];
50sprintf(buff, s, t);
51err(buff);
52}
53
54
55errnm(fmt, l, s)
56char *fmt;
57int l;
58register char *s;
59{
60 char buff[VL+1];
61 register int i;
62
63 i = 0;
64 while (i < l)
65 {
66 buff[i] = s[i];
67 i++;
68 }
69 buff[i] = '\0';
70
71 errstr(fmt, buff);
72}
73
74warnnm(fmt, l, s)
75char *fmt;
76int l;
77register char *s;
78{
79 char buff[VL+1];
80 register int i;
81
82 i = 0;
83 while (i < l)
84 {
85 buff[i] = s[i];
86 i++;
87 }
88 buff[i] = '\0';
89
90 warn1(fmt, buff);
91}
92
93erri(s,t)
94char *s;
95int t;
96{
97char buff[100];
98sprintf(buff, s, t);
99err(buff);
100}
101
102
103err(s)
104char *s;
105{
106fprintf(diagfile, "Error on line %d of %s: %s\n", lineno, infname, s);
107++nerr;
108optoff();
109}
110
111
112yyerror(s)
113char *s;
114{ err(s); }
115
116
117
118dclerr(s, v)
119char *s;
120Namep v;
121{
122char buff[100];
123
124if(v)
125 {
126 sprintf(buff, "Declaration error for %s: %s", varstr(VL, v->varname), s);
127 err(buff);
128 }
129else
130 errstr("Declaration error: %s", s);
131}
132
133
134
135execerr(s, n)
136char *s, *n;
137{
138char buf1[100], buf2[100];
139
140sprintf(buf1, "Execution error: %s", s);
141sprintf(buf2, buf1, n);
142err(buf2);
143}
144
145
146fatal(t)
147char *t;
148{
149fprintf(diagfile, "Compiler error line %d of %s: %s\n", lineno, infname, t);
150if (debugflag[8])
151 showbuffer();
152if (debugflag[0])
153 abort();
154done(3);
155exit(3);
156}
157
158
159
160
161fatalstr(t,s)
162char *t, *s;
163{
164char buff[100];
165sprintf(buff, t, s);
166fatal(buff);
167}
168
169
170
171fatali(t,d)
172char *t;
173int d;
174{
175char buff[100];
176sprintf(buff, t, d);
177fatal(buff);
178}
179
180
181
182badthing(thing, r, t)
183char *thing, *r;
184int t;
185{
186char buff[50];
187sprintf(buff, "Impossible %s %d in routine %s", thing, t, r);
188fatal(buff);
189}
190
191
192
193badop(r, t)
194char *r;
195int t;
196{
197badthing("opcode", r, t);
198}
199
200
201
202badtag(r, t)
203char *r;
204int t;
205{
206badthing("tag", r, t);
207}
208
209
210
211
212
213badstg(r, t)
214char *r;
215int t;
216{
217badthing("storage class", r, t);
218}
219
220
221
222
223badtype(r, t)
224char *r;
225int t;
226{
227badthing("type", r, t);
228}
229
230
231many(s, c)
232char *s, c;
233{
234char buff[25];
235
236sprintf(buff, "Too many %s. Try the -N%c option", s, c);
237fatal(buff);
238}
239
240
241err66(s)
242char *s;
243{
244errstr("Fortran 77 feature used: %s", s);
245}
246
247
248
249errext(s)
250char *s;
251{
252errstr("F77 compiler extension used: %s", s);
253}