xref: /original-bsd/usr.bin/f77/pass1.vax/error.c (revision cd89438c)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)error.c	5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
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 
27 warn1(s,t)
28 char *s, *t;
29 {
30 char buff[100];
31 sprintf(buff, s, t);
32 warn(buff);
33 }
34 
35 
36 warn(s)
37 char *s;
38 {
39 if(nowarnflag)
40 	return;
41 fprintf(diagfile, "Warning on line %d of %s: %s\n", lineno, infname, s);
42 ++nwarn;
43 }
44 
45 
46 errstr(s, t)
47 char *s, *t;
48 {
49 char buff[100];
50 sprintf(buff, s, t);
51 err(buff);
52 }
53 
54 
55 errnm(fmt, l, s)
56 char *fmt;
57 int l;
58 register 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 
74 warnnm(fmt, l, s)
75 char *fmt;
76 int l;
77 register 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 
93 erri(s,t)
94 char *s;
95 int t;
96 {
97 char buff[100];
98 sprintf(buff, s, t);
99 err(buff);
100 }
101 
102 
103 err(s)
104 char *s;
105 {
106 fprintf(diagfile, "Error on line %d of %s: %s\n", lineno, infname, s);
107 ++nerr;
108 optoff();
109 }
110 
111 
112 yyerror(s)
113 char *s;
114 { err(s); }
115 
116 
117 
118 dclerr(s, v)
119 char *s;
120 Namep v;
121 {
122 char buff[100];
123 
124 if(v)
125 	{
126 	sprintf(buff, "Declaration error for %s: %s", varstr(VL, v->varname), s);
127 	err(buff);
128 	}
129 else
130 	errstr("Declaration error: %s", s);
131 }
132 
133 
134 
135 execerr(s, n)
136 char *s, *n;
137 {
138 char buf1[100], buf2[100];
139 
140 sprintf(buf1, "Execution error: %s", s);
141 sprintf(buf2, buf1, n);
142 err(buf2);
143 }
144 
145 
146 fatal(t)
147 char *t;
148 {
149 fprintf(diagfile, "Compiler error line %d of %s: %s\n", lineno, infname, t);
150 if (debugflag[8])
151 	showbuffer();
152 if (debugflag[0])
153 	abort();
154 done(3);
155 exit(3);
156 }
157 
158 
159 
160 
161 fatalstr(t,s)
162 char *t, *s;
163 {
164 char buff[100];
165 sprintf(buff, t, s);
166 fatal(buff);
167 }
168 
169 
170 
171 fatali(t,d)
172 char *t;
173 int d;
174 {
175 char buff[100];
176 sprintf(buff, t, d);
177 fatal(buff);
178 }
179 
180 
181 
182 badthing(thing, r, t)
183 char *thing, *r;
184 int t;
185 {
186 char buff[50];
187 sprintf(buff, "Impossible %s %d in routine %s", thing, t, r);
188 fatal(buff);
189 }
190 
191 
192 
193 badop(r, t)
194 char *r;
195 int t;
196 {
197 badthing("opcode", r, t);
198 }
199 
200 
201 
202 badtag(r, t)
203 char *r;
204 int t;
205 {
206 badthing("tag", r, t);
207 }
208 
209 
210 
211 
212 
213 badstg(r, t)
214 char *r;
215 int t;
216 {
217 badthing("storage class", r, t);
218 }
219 
220 
221 
222 
223 badtype(r, t)
224 char *r;
225 int t;
226 {
227 badthing("type", r, t);
228 }
229 
230 
231 many(s, c)
232 char *s, c;
233 {
234 char buff[25];
235 
236 sprintf(buff, "Too many %s.  Try the -N%c option", s, c);
237 fatal(buff);
238 }
239 
240 
241 err66(s)
242 char *s;
243 {
244 errstr("Fortran 77 feature used: %s", s);
245 }
246 
247 
248 
249 errext(s)
250 char *s;
251 {
252 errstr("F77 compiler extension used: %s", s);
253 }
254