Subject: bin/9632: flex.skl change puts prototype too early, breaks builds
To: None <gnats-bugs@gnats.netbsd.org>
From: None <John.P.Darrow@wheaton.edu>
List: netbsd-bugs
Date: 03/17/2000 15:18:56
>Number:         9632
>Category:       bin
>Synopsis:       flex.skl change puts prototype too early, breaks builds
>Confidential:   yes
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 17 15:18:00 2000
>Last-Modified:
>Originator:     John Darrow
>Organization:
John Darrow - Senior Technical Specialist               Office: 630/752-5201
Computing Services, Wheaton College, Wheaton, IL 60187  Fax:    630/752-5968
Alphapage: 6303160707@alphapage.airtouch.com            Pager:  630/316-0707
Email:     John.P.Darrow@wheaton.edu
>Release:        NetBSD-current 20000317
>Environment:
System: NetBSD jdarrowpiii.wheaton.edu 1.4V NetBSD 1.4V (JDARROW) #0: Fri Mar 17 15:49:59 CST 2000 jdarrow@jdarrowpiii.wheaton.edu:/altroot/var/src/sys/arch/i386/compile/JDARROW i386


>Description:
	The recent change to basesrc/usr.bin/lex/flex.skl (1.12->1.13)
	moved the following block of lines:

static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
#ifndef YY_USES_REJECT
static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
#endif
static void yy_flex_free YY_PROTO(( void * ));

	earlier in the file.  The intention was to move them outside of
	a %- block so that C++ source would get the prototypes, too.
	However, this change moved them too far, and they ended up before
	the location at which the definition of YY_USES_REJECT is injected
	into the file.  As a result, yy_flex_realloc ends up being
	declared but never defined, and a compile of a lex-generated C
	file (for example, basesrc/lib/libc/nslexer.c) breaks, as shown:

cc -O2 -DALL_STATE  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Werror   -D_LIBC -DNLS -DYP -DHESIOD -DLIBC_SCCS -DSYSLIBC_SCCS  -D_REENTRANT -I/var/src/lib/libc/include -DINET6 -D__DBINTERFACE_PRIVATE -DRESOLVSORT -I. -DPOSIX_MISTAKE -DFLOATING_POINT -c -fpic -DPIC /var/src/lib/libc/net/nsdispatch.c -o nsdispatch.so
cc -O2 -DALL_STATE  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Werror   -D_LIBC -DNLS -DYP -DHESIOD -DLIBC_SCCS -DSYSLIBC_SCCS  -D_REENTRANT -I/var/src/lib/libc/include -DINET6 -D__DBINTERFACE_PRIVATE -DRESOLVSORT -I. -DPOSIX_MISTAKE -DFLOATING_POINT -c nslexer.c
cc1: warnings being treated as errors
/dev/stdout:264: warning: `yy_flex_realloc' declared `static' but never defined
*** Error code 1

Stop.
*** Error code 1

Stop.
*** Error code 1

Stop.
*** Error code 1

Stop.

real	9m55.560s
user	3m23.920s
sys	1m43.052s


>How-To-Repeat:
	Complete make build on 2000-03-16.  Attempt make build on
	2000-03-17 (after fixing missing endian_machdep.h install).
	Watch build crater in lib/libc.
>Fix:
	The following patch moves the lines in question back after
 %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
	(where YY_USES_REJECT is defined) but before the %- which
	caused them to be excluded from C++ source files.

	(Someone should also test this against pr 8258 which described
	the original C++ lex problem, but getting the rest of the
	system building again is IMO more urgent...)

Index: /var/src/usr.bin/lex/flex.skl
===================================================================
RCS file: /source/cvs/netbsd/current/src/usr.bin/lex/flex.skl,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 flex.skl
--- flex.skl	2000/03/16 16:55:39	1.1.1.4
+++ flex.skl	2000/03/17 22:46:10
@@ -254,12 +254,6 @@
 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, yy_size_t len ));
 %*
 
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-#ifndef YY_USES_REJECT
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-#endif
-static void yy_flex_free YY_PROTO(( void * ));
-
 #define yy_new_buffer yy_create_buffer
 
 #define yy_set_interactive(is_interactive) \
@@ -279,6 +273,12 @@
 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
 
 %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+#ifndef YY_USES_REJECT
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+#endif
+static void yy_flex_free YY_PROTO(( void * ));
 
 %- Standard (non-C++) definition
 static yy_state_type yy_get_previous_state YY_PROTO(( void ));

>Audit-Trail:
>Unformatted: