summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-10-05 15:38:23 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:57:04 +0000
commitc701d88756fa135c2016cbf968970d37ec67e26c (patch)
tree415f6994c734219f388a4231499691e7da6be5af /src
parent834846f80259522612d966657d68db3fb10ea90c (diff)
downloadgem5-c701d88756fa135c2016cbf968970d37ec67e26c.tar.xz
systemc: Add an error check to sc_gen_unique_name.
Accellera checks for a null pointer, and a test tries using that input. Change-Id: I0f098f53de37ebbe481ea46e61fc0a9a404c29db Reviewed-on: https://gem5-review.googlesource.com/c/13302 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/systemc/core/sc_module.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 175b9db63..0b58f3232 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -822,12 +822,20 @@ at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
const char *
sc_gen_unique_name(const char *seed)
{
+ if (!seed || seed[0] == '\0') {
+ SC_REPORT_ERROR(
+ "(E532) cannot generate unique name from null string", "");
+ seed = "unnamed";
+ }
+
auto mod = sc_gem5::pickParentModule();
if (mod)
return mod->uniqueName(seed);
+
sc_gem5::Process *p = sc_gem5::scheduler.current();
if (p)
return p->uniqueName(seed);
+
return ::sc_gem5::nameGen.gen(seed);
}