1*47955Sbostic /*-
2*47955Sbostic * Copyright (c) 1980 The Regents of the University of California.
3*47955Sbostic * All rights reserved.
4*47955Sbostic *
5*47955Sbostic * %sccs.include.proprietary.c%
622807Smckusick */
722807Smckusick
822807Smckusick #ifndef lint
9*47955Sbostic static char sccsid[] = "@(#)error.c 5.2 (Berkeley) 04/12/91";
10*47955Sbostic #endif /* not lint */
1122807Smckusick
1222807Smckusick /*
1322807Smckusick * error.c
1422807Smckusick *
1522807Smckusick * Error handling routines for f77 compiler pass 1, 4.2 BSD.
1622807Smckusick *
1722807Smckusick * University of Utah CS Dept modification history:
1822807Smckusick *
1922807Smckusick * Revision 1.2 84/08/20 17:57:20 donn
2022807Smckusick * Added strategic colons to the format strings in execerr() and dclerr().
2122807Smckusick *
2222807Smckusick */
2322807Smckusick
2422807Smckusick #include "defs.h"
2522807Smckusick
2622807Smckusick
warn1(s,t)2722807Smckusick warn1(s,t)
2822807Smckusick char *s, *t;
2922807Smckusick {
3022807Smckusick char buff[100];
3122807Smckusick sprintf(buff, s, t);
3222807Smckusick warn(buff);
3322807Smckusick }
3422807Smckusick
3522807Smckusick
warn(s)3622807Smckusick warn(s)
3722807Smckusick char *s;
3822807Smckusick {
3922807Smckusick if(nowarnflag)
4022807Smckusick return;
4122807Smckusick fprintf(diagfile, "Warning on line %d of %s: %s\n", lineno, infname, s);
4222807Smckusick ++nwarn;
4322807Smckusick }
4422807Smckusick
4522807Smckusick
errstr(s,t)4622807Smckusick errstr(s, t)
4722807Smckusick char *s, *t;
4822807Smckusick {
4922807Smckusick char buff[100];
5022807Smckusick sprintf(buff, s, t);
5122807Smckusick err(buff);
5222807Smckusick }
5322807Smckusick
5422807Smckusick
errnm(fmt,l,s)5522807Smckusick errnm(fmt, l, s)
5622807Smckusick char *fmt;
5722807Smckusick int l;
5822807Smckusick register char *s;
5922807Smckusick {
6022807Smckusick char buff[VL+1];
6122807Smckusick register int i;
6222807Smckusick
6322807Smckusick i = 0;
6422807Smckusick while (i < l)
6522807Smckusick {
6622807Smckusick buff[i] = s[i];
6722807Smckusick i++;
6822807Smckusick }
6922807Smckusick buff[i] = '\0';
7022807Smckusick
7122807Smckusick errstr(fmt, buff);
7222807Smckusick }
7322807Smckusick
warnnm(fmt,l,s)7422807Smckusick warnnm(fmt, l, s)
7522807Smckusick char *fmt;
7622807Smckusick int l;
7722807Smckusick register char *s;
7822807Smckusick {
7922807Smckusick char buff[VL+1];
8022807Smckusick register int i;
8122807Smckusick
8222807Smckusick i = 0;
8322807Smckusick while (i < l)
8422807Smckusick {
8522807Smckusick buff[i] = s[i];
8622807Smckusick i++;
8722807Smckusick }
8822807Smckusick buff[i] = '\0';
8922807Smckusick
9022807Smckusick warn1(fmt, buff);
9122807Smckusick }
9222807Smckusick
erri(s,t)9322807Smckusick erri(s,t)
9422807Smckusick char *s;
9522807Smckusick int t;
9622807Smckusick {
9722807Smckusick char buff[100];
9822807Smckusick sprintf(buff, s, t);
9922807Smckusick err(buff);
10022807Smckusick }
10122807Smckusick
10222807Smckusick
err(s)10322807Smckusick err(s)
10422807Smckusick char *s;
10522807Smckusick {
10622807Smckusick fprintf(diagfile, "Error on line %d of %s: %s\n", lineno, infname, s);
10722807Smckusick ++nerr;
10822807Smckusick optoff();
10922807Smckusick }
11022807Smckusick
11122807Smckusick
yyerror(s)11222807Smckusick yyerror(s)
11322807Smckusick char *s;
11422807Smckusick { err(s); }
11522807Smckusick
11622807Smckusick
11722807Smckusick
dclerr(s,v)11822807Smckusick dclerr(s, v)
11922807Smckusick char *s;
12022807Smckusick Namep v;
12122807Smckusick {
12222807Smckusick char buff[100];
12322807Smckusick
12422807Smckusick if(v)
12522807Smckusick {
12622807Smckusick sprintf(buff, "Declaration error for %s: %s", varstr(VL, v->varname), s);
12722807Smckusick err(buff);
12822807Smckusick }
12922807Smckusick else
13022807Smckusick errstr("Declaration error: %s", s);
13122807Smckusick }
13222807Smckusick
13322807Smckusick
13422807Smckusick
execerr(s,n)13522807Smckusick execerr(s, n)
13622807Smckusick char *s, *n;
13722807Smckusick {
13822807Smckusick char buf1[100], buf2[100];
13922807Smckusick
14022807Smckusick sprintf(buf1, "Execution error: %s", s);
14122807Smckusick sprintf(buf2, buf1, n);
14222807Smckusick err(buf2);
14322807Smckusick }
14422807Smckusick
14522807Smckusick
fatal(t)14622807Smckusick fatal(t)
14722807Smckusick char *t;
14822807Smckusick {
14922807Smckusick fprintf(diagfile, "Compiler error line %d of %s: %s\n", lineno, infname, t);
15022807Smckusick if (debugflag[8])
15122807Smckusick showbuffer();
15222807Smckusick if (debugflag[0])
15322807Smckusick abort();
15422807Smckusick done(3);
15522807Smckusick exit(3);
15622807Smckusick }
15722807Smckusick
15822807Smckusick
15922807Smckusick
16022807Smckusick
fatalstr(t,s)16122807Smckusick fatalstr(t,s)
16222807Smckusick char *t, *s;
16322807Smckusick {
16422807Smckusick char buff[100];
16522807Smckusick sprintf(buff, t, s);
16622807Smckusick fatal(buff);
16722807Smckusick }
16822807Smckusick
16922807Smckusick
17022807Smckusick
fatali(t,d)17122807Smckusick fatali(t,d)
17222807Smckusick char *t;
17322807Smckusick int d;
17422807Smckusick {
17522807Smckusick char buff[100];
17622807Smckusick sprintf(buff, t, d);
17722807Smckusick fatal(buff);
17822807Smckusick }
17922807Smckusick
18022807Smckusick
18122807Smckusick
badthing(thing,r,t)18222807Smckusick badthing(thing, r, t)
18322807Smckusick char *thing, *r;
18422807Smckusick int t;
18522807Smckusick {
18622807Smckusick char buff[50];
18722807Smckusick sprintf(buff, "Impossible %s %d in routine %s", thing, t, r);
18822807Smckusick fatal(buff);
18922807Smckusick }
19022807Smckusick
19122807Smckusick
19222807Smckusick
badop(r,t)19322807Smckusick badop(r, t)
19422807Smckusick char *r;
19522807Smckusick int t;
19622807Smckusick {
19722807Smckusick badthing("opcode", r, t);
19822807Smckusick }
19922807Smckusick
20022807Smckusick
20122807Smckusick
badtag(r,t)20222807Smckusick badtag(r, t)
20322807Smckusick char *r;
20422807Smckusick int t;
20522807Smckusick {
20622807Smckusick badthing("tag", r, t);
20722807Smckusick }
20822807Smckusick
20922807Smckusick
21022807Smckusick
21122807Smckusick
21222807Smckusick
badstg(r,t)21322807Smckusick badstg(r, t)
21422807Smckusick char *r;
21522807Smckusick int t;
21622807Smckusick {
21722807Smckusick badthing("storage class", r, t);
21822807Smckusick }
21922807Smckusick
22022807Smckusick
22122807Smckusick
22222807Smckusick
badtype(r,t)22322807Smckusick badtype(r, t)
22422807Smckusick char *r;
22522807Smckusick int t;
22622807Smckusick {
22722807Smckusick badthing("type", r, t);
22822807Smckusick }
22922807Smckusick
23022807Smckusick
many(s,c)23122807Smckusick many(s, c)
23222807Smckusick char *s, c;
23322807Smckusick {
23422807Smckusick char buff[25];
23522807Smckusick
23622807Smckusick sprintf(buff, "Too many %s. Try the -N%c option", s, c);
23722807Smckusick fatal(buff);
23822807Smckusick }
23922807Smckusick
24022807Smckusick
err66(s)24122807Smckusick err66(s)
24222807Smckusick char *s;
24322807Smckusick {
24422807Smckusick errstr("Fortran 77 feature used: %s", s);
24522807Smckusick }
24622807Smckusick
24722807Smckusick
24822807Smckusick
errext(s)24922807Smckusick errext(s)
25022807Smckusick char *s;
25122807Smckusick {
25222807Smckusick errstr("F77 compiler extension used: %s", s);
25322807Smckusick }
254