summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-12-27 16:25:27 +0100
committerClifford Wolf <clifford@clifford.at>2013-12-27 16:25:27 +0100
commit1dcbba1abf28afae846bd42f49d716892ffd685c (patch)
treeb831aa99e9b64f4e1fce70fce91ededefc742b61 /frontends
parent0f5ab7649e4496b1923cad6f093c735a2350fdc8 (diff)
Fixed parsing of non-arg macro calls followed by "("
Diffstat (limited to 'frontends')
-rw-r--r--frontends/verilog/preproc.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/frontends/verilog/preproc.cc b/frontends/verilog/preproc.cc
index 501adf05..5cfa0f24 100644
--- a/frontends/verilog/preproc.cc
+++ b/frontends/verilog/preproc.cc
@@ -204,6 +204,7 @@ static void input_file(FILE *f, std::string filename)
std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::map<std::string, std::string> pre_defines_map, const std::list<std::string> include_dirs)
{
+ std::set<std::string> defines_with_args;
std::map<std::string, std::string> defines_map(pre_defines_map);
int ifdef_fail_level = 0;
bool in_elseif = false;
@@ -354,6 +355,10 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m
return_char('\n');
// printf("define: >>%s<< -> >>%s<<\n", name.c_str(), value.c_str());
defines_map[name] = value;
+ if (state == 2)
+ defines_with_args.insert(name);
+ else
+ defines_with_args.erase(name);
continue;
}
@@ -363,6 +368,7 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m
name = next_token(true);
// printf("undef: >>%s<<\n", name.c_str());
defines_map.erase(name);
+ defines_with_args.erase(name);
continue;
}
@@ -381,7 +387,7 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m
// printf("expand: >>%s<< -> >>%s<<\n", name.c_str(), defines_map[name].c_str());
std::string skipped_spaces = skip_spaces();
tok = next_token(true);
- if (tok == "(") {
+ if (tok == "(" && defines_with_args.count(name) > 0) {
int level = 1;
std::vector<std::string> args;
args.push_back(std::string());