mem-cache: Assert Entry inherits from QueueEntry in Queue
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Thu, 24 Jan 2019 14:13:07 +0000 (15:13 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Fri, 19 Apr 2019 16:34:00 +0000 (16:34 +0000)
Queue has several assumptions regarding its template parameter,
so make sure they are fulfilled by forcing Entry to be derived
from QueueEntry.

Change-Id: I0203a62aec00c04ac89e9674d86a44a07f9f13ab
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17529
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/queue.hh

index 36ddb96c2f6a697e502c119aa31899fe9d340bd8..6c8a192655ecc8c99d8c411c17fb58ff16f05cfd 100644 (file)
@@ -51,6 +51,7 @@
 
 #include <cassert>
 #include <string>
+#include <type_traits>
 
 #include "base/logging.hh"
 #include "base/trace.hh"
@@ -68,6 +69,9 @@
 template<class Entry>
 class Queue : public Drainable
 {
+    static_assert(std::is_base_of<QueueEntry, Entry>::value,
+        "Entry must be derived from QueueEntry");
+
   protected:
     /** Local label (for functional print requests) */
     const std::string label;