[4bsd-f77 #26] F77 sometimes doesn't detect missing ENDIFs
4.2 BSD f77 bug reports
4bsd-f77 at utah-cs.UUCP
Thu Aug 2 09:28:45 AEST 1984
From: Donn Seeley <donn at utah-cs.arpa>
Subject: F77 sometimes doesn't detect missing ENDIFs
Index: usr.bin/f77/src/f77pass1/exec.c 4.2BSD
Description:
When a block IF is missing its ENDIF at the end of a DO loop,
instead of a syntax error the compiler prints a warning from
the assembler and bombs in the loader. This bug was brought
to my attention by Jay Chalmers at the HAO.
Repeat-By:
Clip out this routine and try to compile it down to object
code:
----------------------------------------------------------------
subroutine noendif( x )
real x
integer i, j
do 100 i = 1, 10
if (x .gt. 3.0) then
do 100 j = 1, 10
x = x + x ** j
100 continue
return
end
----------------------------------------------------------------
No syntax error will be reported and the assembler will make a
complaint of this sort:
----------------------------------------------------------------
"/tmp/fort3061.s", line 22: WARNING: bleq: destination label is external
----------------------------------------------------------------
Fix:
The problem is that the compiler stacks the blocks of IFs and
DO loops in a data structure called 'ctlstack', but doesn't use
this information for detecting unclosed blocks at the ends of
DO loops. The fix to enddo() in exec.c is simple:
----------------------------------------------------------------
*** /tmp/,RCSt1003739 Thu Jul 12 18:43:15 1984
--- exec.c Thu Jul 12 18:35:58 1984
***************
*** 607,612
while (here == dorange)
{
if (np = ctlstack->donamep)
{
rv = mkplace (np);
--- 610,621 -----
while (here == dorange)
{
+ while (ctlstack->ctltype == CTLIF || ctlstack->ctltype == CTLELSE)
+ {
+ execerr("missing endif", CNULL);
+ exendif();
+ }
+
if (np = ctlstack->donamep)
{
rv = mkplace (np);
----------------------------------------------------------------
Donn Seeley University of Utah CS Dept donn at utah-cs.arpa
40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list