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;
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;
}
name = next_token(true);
// printf("undef: >>%s<<\n", name.c_str());
defines_map.erase(name);
+ defines_with_args.erase(name);
continue;
}
// 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());