BSD 4_3 development
[unix-history] / usr / src / usr.bin / efl / error.c
CommitLineData
832026c6
C
1#include "defs"
2
3char *linerr()
4{
5static char buff[50];
6register int i;
7
8for(i = filedepth; i>0 && filenames[i]==NULL ; --i)
9 ;
10if(i > 0)
11 sprintf(buff, "on line %d of file %s", yylineno, filenames[i]);
12else
13 sprintf(buff, "on line %d", yylineno);
14return(buff);
15}
16
17
18
19laberr(s,t)
20char *s;
21char *t;
22{
23errmess("Label error", s, t);
24}
25
26
27
28
29
30exprerr(s,t)
31char *s;
32ptr t;
33{
34errmess("Expression error", s, t);
35}
36
37
38
39
40execerr(s,t)
41char *s, *t;
42{
43errmess("Error", s, t);
44}
45
46
47errmess(m,s,t)
48char *m, *s, *t;
49{
50fprintf(diagfile, "**%s %s: ", m, linerr());
51if(s)
52 fprintf(diagfile, s, t);
53fprintf(diagfile, "\n");
54++nerrs;
55}
56
57
58
59dclerr(s, n)
60char *s, *n;
61{
62extern int nerrs;
63
64fprintf(diagfile, "**Error %s: Declaration for %s: %s\n",
65 linerr(), n, s);
66++nerrs;
67}
68
69
70
71
72badtag(routine, tag)
73char *routine;
74int tag;
75{
76char buff[100];
77sprintf(buff, "impossible tag %d in routine %s", tag, routine);
78fatal(buff);
79}
80
81
82
83fatal1(s,t)
84char *s;
85int t;
86{
87
88sprintf(msg, s, t);
89fatal(msg);
90}
91
92
93
94fatal(s)
95char *s;
96{
97fprintf(diagfile, "\n***Compiler error %s.", linerr());
98if(s) fprintf(diagfile, " %s.", s);
99fprintf(diagfile, "\n");
100fflush(stdout);
101
102if(dumpcore)
103 abort(0);
104else {
105 rmiis();
106 exit(-1);
107 }
108}
109
110
111
112warn1(s,t)
113char *s;
114int t;
115{
116sprintf(msg, s, t);
117warn(msg);
118}
119
120
121
122
123warn(s)
124char *s;
125{
126++nwarns;
127if( !nowarnflag)
128 fprintf(diagfile, "*Warning: %s\n", s);
129}
130
131
132
133yyerror(s)
134char *s;
135{
136errmess(s, CNULL, CNULL);
137}