summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-05-12 22:33:05 -0700
committerNathan Binkert <nate@binkert.org>2009-05-12 22:33:05 -0700
commit0c2b9cf90dc7c63f8d102a0d4285101a03bc5b91 (patch)
tree78b424b805503e246d9af9457a16ddd8f8617cc4 /src
parentd923ce0f8ca6a534b1127664792b936f22677a77 (diff)
downloadgem5-0c2b9cf90dc7c63f8d102a0d4285101a03bc5b91.tar.xz
slicc: work around improper initialization of a global in slicc.
Diffstat (limited to 'src')
-rw-r--r--src/mem/slicc/ast/Location.cc8
-rw-r--r--src/mem/slicc/ast/Location.hh2
-rw-r--r--src/mem/slicc/parser/parser.yy4
3 files changed, 9 insertions, 5 deletions
diff --git a/src/mem/slicc/ast/Location.cc b/src/mem/slicc/ast/Location.cc
index 6209ccdb7..23d1dba0f 100644
--- a/src/mem/slicc/ast/Location.cc
+++ b/src/mem/slicc/ast/Location.cc
@@ -39,11 +39,15 @@
#include "mem/slicc/ast/Location.hh"
int g_line_number = 0;
-string g_file_name("");
+string &g_file_name()
+{
+ static string the_string;
+ return the_string;
+}
Location::Location()
{
- m_file_name = g_file_name;
+ m_file_name = g_file_name();
m_line_number = g_line_number;
ostringstream sstr;
diff --git a/src/mem/slicc/ast/Location.hh b/src/mem/slicc/ast/Location.hh
index f070efc46..3233bdb3b 100644
--- a/src/mem/slicc/ast/Location.hh
+++ b/src/mem/slicc/ast/Location.hh
@@ -42,7 +42,7 @@
#include "mem/slicc/slicc_global.hh"
extern int g_line_number;
-extern string g_file_name;
+extern string &g_file_name();
class Location {
public:
diff --git a/src/mem/slicc/parser/parser.yy b/src/mem/slicc/parser/parser.yy
index 8090b88f7..724184665 100644
--- a/src/mem/slicc/parser/parser.yy
+++ b/src/mem/slicc/parser/parser.yy
@@ -337,7 +337,7 @@ DeclListAST* parse(string filename)
exit(1);
}
g_line_number = 1;
- g_file_name = filename;
+ g_file_name() = filename;
yyin = file;
g_decl_list_ptr = NULL;
yyparse();
@@ -346,7 +346,7 @@ DeclListAST* parse(string filename)
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);
}