From 4c639e171abae185a6e0aa0bb908c0e1e37547b7 Mon Sep 17 00:00:00 2001
From: Gabe Black <gabeblack@google.com>
Date: Sat, 1 Sep 2018 16:37:55 -0700
Subject: systemc: Report an error if n <= 0 in wait(int n).

This is in the spec, and tested by one of the regression tests.

Change-Id: I035cfad279be3859242919a95598f191d5d06165
Reviewed-on: https://gem5-review.googlesource.com/c/12458
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
---
 src/systemc/core/sc_module.cc | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'src/systemc')

diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 44e442d00..6be3818da 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -575,6 +575,10 @@ wait()
 void
 wait(int n)
 {
+    if (n <= 0) {
+        std::string msg = csprintf("n = %d", n);
+        SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
+    }
     for (int i = 0; i < n; i++)
         wait();
 }
-- 
cgit v1.2.3