Subject: bin/23427: Flex C++ scanners no longer work with gcc 3
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <audun@stud.cs.uit.no>
List: netbsd-bugs
Date: 11/13/2003 23:31:03
>Number: 23427
>Category: bin
>Synopsis: Flex C++ scanners no longer work with gcc 3
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 13 23:32:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Audun Nordal
>Release: 1.6ZC i386
>Organization:
>Environment:
NetBSD vlab1 1.6ZC NetBSD 1.6ZC (GENERIC) #0: Tue Sep 30 01:15:20 UTC 2003 autobuild@tgm.netbsd.org:/autobuild/HEAD/i386/OBJ/autobuild/HEAD/src/sys/arch/i386/compile/GENERIC i386
>Description:
The flex scanner generator has drifted out of sync on current. There are a number of patches for various problems floating around, but the most serious problem is that the generated C++ scanners do not compile on gcc 3.x (apparently, it isn't C++ 98). I hereby request that at least the patches in e.g. Gentoo linux' sys-devel/flex package to be applied. I would have liked to point to a better location, but the flex directory seems to have been removed from ftp.gnu.org.
It looks like this also applies to pkgsrc/devel/flex
>How-To-Repeat:
To test the C++ problem, build the following scanner
<begin>
%%
%%
<end>
>Fix:
C++ fixes for gcc 3 from gentoo:
http://www.gentoo.org/cgi-bin/viewcvs.cgi/sys-devel/flex/files/flex-2.5.4a-gcc3.patch
http://www.gentoo.org/cgi-bin/viewcvs.cgi/sys-devel/flex/files/flex-2.5.4a-gcc31.patch
They apply more or less cleanly, below is my diff to current after patching
Index: FlexLexer.h
===================================================================
RCS file: /cvsroot/src/usr.bin/lex/FlexLexer.h,v
retrieving revision 1.8
diff -u -r1.8 FlexLexer.h
--- FlexLexer.h 1998/01/05 05:15:43 1.8
+++ FlexLexer.h 2003/11/13 23:26:40
@@ -43,7 +43,7 @@
#ifndef __FLEX_LEXER_H
// Never included before - need to define base class.
#define __FLEX_LEXER_H
-#include <iostream.h>
+#include <iostream>
extern "C++" {
@@ -60,14 +60,14 @@
virtual void
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
virtual struct yy_buffer_state*
- yy_create_buffer( istream* s, int size ) = 0;
+ yy_create_buffer( std::istream* s, int size ) = 0;
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
- virtual void yyrestart( istream* s ) = 0;
+ virtual void yyrestart( std::istream* s ) = 0;
virtual int yylex() = 0;
// Call yylex with new input/output sources.
- int yylex( istream* new_in, ostream* new_out = 0 )
+ int yylex( std::istream* new_in, std::ostream* new_out = 0 )
{
switch_streams( new_in, new_out );
return yylex();
@@ -75,8 +75,8 @@
// Switch to new input/output streams. A nil stream pointer
// indicates "keep the current one".
- virtual void switch_streams( istream* new_in = 0,
- ostream* new_out = 0 ) = 0;
+ virtual void switch_streams( std::istream* new_in = 0,
+ std::ostream* new_out = 0 ) = 0;
int lineno() const { return yylineno; }
@@ -103,17 +103,17 @@
public:
// arg_yyin and arg_yyout default to the cin and cout, but we
// only make that assignment when initializing in yylex().
- yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
+ yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
virtual ~yyFlexLexer();
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
- struct yy_buffer_state* yy_create_buffer( istream* s, int size );
+ struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );
void yy_delete_buffer( struct yy_buffer_state* b );
- void yyrestart( istream* s );
+ void yyrestart( std::istream* s );
virtual int yylex();
- virtual void switch_streams( istream* new_in, ostream* new_out );
+ virtual void switch_streams( std::istream* new_in, std::ostream* new_out
);
protected:
virtual int LexerInput( char* buf, int max_size );
@@ -124,7 +124,7 @@
int yyinput();
void yy_load_buffer_state();
- void yy_init_buffer( struct yy_buffer_state* b, istream* s );
+ void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );
void yy_flush_buffer( struct yy_buffer_state* b );
int yy_start_stack_ptr;
@@ -139,8 +139,8 @@
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
- istream* yyin; // input source for default LexerInput
- ostream* yyout; // output sink for default LexerOutput
+ std::istream* yyin; // input source for default LexerInput
+ std::ostream* yyout; // output sink for default LexerOutput
struct yy_buffer_state* yy_current_buffer;
Index: flex.skl
===================================================================
RCS file: /cvsroot/src/usr.bin/lex/flex.skl,v
retrieving revision 1.16
diff -u -r1.16 flex.skl
--- flex.skl 2001/01/06 02:09:31 1.16
+++ flex.skl 2003/11/13 23:26:40
@@ -25,7 +25,8 @@
#include <stdlib.h>
%+
-class istream;
+#include <iostream>
+using namespace std;
%*
#include <unistd.h>
>Release-Note:
>Audit-Trail:
>Unformatted: