diff --git a/src/script_opt/CPP/Util.cc b/src/script_opt/CPP/Util.cc index 1c64c9af21..f41f225a41 100644 --- a/src/script_opt/CPP/Util.cc +++ b/src/script_opt/CPP/Util.cc @@ -1,5 +1,6 @@ // See the file "COPYING" in the main distribution directory for copyright. +#include "zeek/script_opt/StmtOptInfo.h" #include "zeek/script_opt/CPP/Util.h" #include @@ -50,6 +51,14 @@ bool is_CPP_compilable(const ProfileFunc* pf, const char** reason) return false; } + auto body = pf->ProfiledBody(); + if ( body && ! body->GetOptInfo()->is_free_of_conditionals ) + { + if ( reason ) + *reason = "body may be affected by @if conditional"; + return false; + } + return true; }