From 85a8f0739c6aa948723786e86c9e0df5fa441039 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 5 Aug 2024 09:24:47 +0100 Subject: [PATCH] run-time warnings for scripts compiled to C++ --- src/Reporter.cc | 8 ++++++++ src/Reporter.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/Reporter.cc b/src/Reporter.cc index 47950735c4..81da38db7b 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -203,6 +203,14 @@ void Reporter::CPPRuntimeError(const char* fmt, ...) { throw InterpreterException(); } +void Reporter::CPPRuntimeWarning(const char* fmt, ...) { + va_list ap; + va_start(ap, fmt); + FILE* out = EmitToStderr(warnings_to_stderr) ? stderr : nullptr; + DoLog("runtime warning in compiled code", reporter_error, out, nullptr, nullptr, true, true, "", fmt, ap); + va_end(ap); +} + void Reporter::InternalError(const char* fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/src/Reporter.h b/src/Reporter.h index 2107f137ff..d67a68c5a8 100644 --- a/src/Reporter.h +++ b/src/Reporter.h @@ -115,6 +115,9 @@ public: // function will not return but raise an InterpreterException. [[noreturn]] void CPPRuntimeError(const char* fmt, ...) __attribute__((format(printf, 2, 3))); + // Similar, but for warnings. This function does return. + void CPPRuntimeWarning(const char* fmt, ...) __attribute__((format(printf, 2, 3))); + // Report a traffic weirdness, i.e., an unexpected protocol situation // that may lead to incorrectly processing a connection. void Weird(const char* name, const char* addl = "",