]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - con.c
Error when the assignop for an assignment is invalid, eg. when trying to assign arrays
[xonotic/gmqcc.git] / con.c
diff --git a/con.c b/con.c
index 2bd8e397de579096f017b421ce5ba783ff4cecf2..1cd7b326d10956192bb16983f538ac6744c65767 100644 (file)
--- a/con.c
+++ b/con.c
@@ -22,6 +22,9 @@
  */
 #include "gmqcc.h"
 
+uint32_t    opts_warn [1 + (COUNT_WARNINGS / 32)];
+bool        opts_werror   = false;
+
 /*
  * isatty/STDERR_FILENO/STDOUT_FILNO
  * + some other things likewise.
@@ -360,3 +363,38 @@ void con_cprintmsg (void *ctx, int lvl, const char *msgtype, const char *msg, ..
     con_cvprintmsg(ctx, lvl, msgtype, msg, va);
     va_end  (va);
 }
+
+/* General error interface */
+size_t compile_errors = 0;
+size_t compile_warnings = 0;
+
+void compile_error(lex_ctx ctx, const char *msg, ...)
+{
+    va_list ap;
+    ++compile_errors;
+    va_start(ap, msg);
+    con_cvprintmsg((void*)&ctx, LVL_ERROR, "error", msg, ap);
+    va_end(ap);
+}
+
+bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...)
+{
+    va_list ap;
+    int lvl = LVL_WARNING;
+
+    if (!OPTS_WARN(warntype))
+        return false;
+
+    if (opts_werror) {
+        ++compile_errors;
+        lvl = LVL_ERROR;
+    }
+    else
+        ++compile_warnings;
+
+    va_start(ap, fmt);
+    con_vprintmsg(lvl, ctx.file, ctx.line, (opts_werror ? "error" : "warning"), fmt, ap);
+    va_end(ap);
+
+    return opts_werror;
+}