slicc: work around improper initialization of a global in slicc.
This commit is contained in:
parent
d923ce0f8c
commit
0c2b9cf90d
|
@ -39,11 +39,15 @@
|
||||||
#include "mem/slicc/ast/Location.hh"
|
#include "mem/slicc/ast/Location.hh"
|
||||||
|
|
||||||
int g_line_number = 0;
|
int g_line_number = 0;
|
||||||
string g_file_name("");
|
string &g_file_name()
|
||||||
|
{
|
||||||
|
static string the_string;
|
||||||
|
return the_string;
|
||||||
|
}
|
||||||
|
|
||||||
Location::Location()
|
Location::Location()
|
||||||
{
|
{
|
||||||
m_file_name = g_file_name;
|
m_file_name = g_file_name();
|
||||||
m_line_number = g_line_number;
|
m_line_number = g_line_number;
|
||||||
|
|
||||||
ostringstream sstr;
|
ostringstream sstr;
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "mem/slicc/slicc_global.hh"
|
#include "mem/slicc/slicc_global.hh"
|
||||||
|
|
||||||
extern int g_line_number;
|
extern int g_line_number;
|
||||||
extern string g_file_name;
|
extern string &g_file_name();
|
||||||
|
|
||||||
class Location {
|
class Location {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -337,7 +337,7 @@ DeclListAST* parse(string filename)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
g_line_number = 1;
|
g_line_number = 1;
|
||||||
g_file_name = filename;
|
g_file_name() = filename;
|
||||||
yyin = file;
|
yyin = file;
|
||||||
g_decl_list_ptr = NULL;
|
g_decl_list_ptr = NULL;
|
||||||
yyparse();
|
yyparse();
|
||||||
|
@ -346,7 +346,7 @@ DeclListAST* parse(string filename)
|
||||||
|
|
||||||
extern "C" void yyerror(char* s)
|
extern "C" void yyerror(char* s)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s:%d: %s at %s\n", g_file_name.c_str(), g_line_number, s, yytext);
|
fprintf(stderr, "%s:%d: %s at %s\n", g_file_name().c_str(), g_line_number, s, yytext);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue