Subject: bin/8258: lex doesn't produce correct output for C++
To: None <gnats-bugs@gnats.netbsd.org>
From: None <nick@nthcliff.demon.co.uk>
List: netbsd-bugs
Date: 08/23/1999 19:15:47
>Number:         8258
>Category:       bin
>Synopsis:       lex doesn't produce correct output for C++
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 23 18:05:04 1999
>Last-Modified:
>Originator:     Nick Hudson
>Organization:
none
>Release:        1.4.1
>Environment:
NetBSD nthcliff 1.4.1 NetBSD 1.4.1 (NTHCLIFF) #0: Thu Jul 29 19:41:02 BST 1999     root@nthcliff:/usr/src-1.4.1/sys/arch/i386/compile/NTHCLIFF i386
>Description:
See summary
>How-To-Repeat:
Use lex with -+ option and compile resulting code and see warnings

$ lex -+ tokenizer.l
$ g++ lex.yy.cc
lex.yy.cc: In method `struct yy_buffer_state * yyFlexLexer::yy_create_buffer(class istream *, int)':
lex.yy.cc:1759: warning: implicit declaration of function `int yy_flex_alloc(...)'
lex.yy.cc: In method `void yyFlexLexer::yy_delete_buffer(struct yy_buffer_state *)':
lex.yy.cc:1789: warning: implicit declaration of function `int yy_flex_free(...)'              

>Fix:
Apply the following patch to flex.skl. This brings the files into line with flex 2.5.4
$ diff -u flex.skl.orig flex.skl
--- flex.skl.orig       Tue Jan 19 12:13:11 1999
+++ flex.skl    Mon Aug 23 22:10:23 1999
@@ -254,6 +254,10 @@
 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 ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
 #define yy_new_buffer yy_create_buffer

 #define yy_set_interactive(is_interactive) \
@@ -275,11 +279,6 @@
 %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here

 %- Standard (non-C++) definition
-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 * ));
 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
 static int yy_get_next_buffer YY_PROTO(( void ));

>Audit-Trail:
>Unformatted: