From 50a404834f1aed0d29c84009b00f1454cac3e521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Ha=CC=88user?= <mhaeuser@posteo.de> Date: Sat, 25 Nov 2023 20:37:08 +0100 Subject: [PATCH] simulator: add failsafe for stochastic guards Stochastic guards are supposed to be generated in a way that the if branches are disjoint and exhaustive. Compilers have trouble verifying the latter property, as they usually do not pick up postconditions on return value of myrand(0, 99). To silence warnings regarded control paths that do not return a value, and to add hardening against code generation bugs that actually violate exhaustion of the if branches, assert() and abort() at the end of such functions. --- .../java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java b/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java index 18e40fb318..1069857f6a 100644 --- a/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java +++ b/src/main/java/tmltranslator/tomappingsystemc2/MappedSystemCTask.java @@ -845,6 +845,7 @@ public class MappedSystemCTask { noOfGuards++; } } + code += "assert(false)" + SCCR + "abort()" + SCCR; } else { int indElseGuard = choice.getElseGuard(), newIndElseGuard = -1; -- GitLab