run-time warnings for scripts compiled to C++

This commit is contained in:
Vern Paxson 2024-08-05 09:24:47 +01:00 committed by Arne Welzel
parent b333d24e0e
commit 85a8f0739c
2 changed files with 11 additions and 0 deletions

View file

@ -203,6 +203,14 @@ void Reporter::CPPRuntimeError(const char* fmt, ...) {
throw InterpreterException(); 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, ...) { void Reporter::InternalError(const char* fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);

View file

@ -115,6 +115,9 @@ public:
// function will not return but raise an InterpreterException. // function will not return but raise an InterpreterException.
[[noreturn]] void CPPRuntimeError(const char* fmt, ...) __attribute__((format(printf, 2, 3))); [[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 // Report a traffic weirdness, i.e., an unexpected protocol situation
// that may lead to incorrectly processing a connection. // that may lead to incorrectly processing a connection.
void Weird(const char* name, const char* addl = "", void Weird(const char* name, const char* addl = "",