enables several warnings when static typechecking cannot guarantee
consistent behavior.
.It Fl W Ns Cm breakdef
-When compiling original id1 QC, there is a definition for `break`
+When compiling original id1 QC there is a definition for `break`
which conflicts with the 'break' keyword in GMQCC. Enabling this
-warning will print a warning when the definition occurs. The
-definition is ignored for both cases.
+will print a warning when the definition occurs. The definition is
+ignored for both cases.
+.It Fl W Ns Cm const-overwrite
+When compiling original QuakeWorld QC there are instances where
+code overwrites constants. This is considered an error, however
+for QuakeWorld to compile it needs to be treated as a warning
+instead, as such this warning only works when -std=qcc.
.El
.Sh COMPILE FLAGS
.Bl -tag -width Ds
#write a ticket.
FTEPP = true
-
+
#Enable some predefined macros. This only works in combination
#with '-fftepp' and is currently not included by '-std=fteqcc'.
UNSAFE_TYPES = true
- #When compiling original id1 QC, there is a definition for `break`
+ #When compiling original id1 QC there is a definition for `break`
#which conflicts with the 'break' keyword in GMQCC. Enabling this
- #warning will print a warning when the definition occurs. The
- #definition is ignored for both cases.
+ #print a warning when the definition occurs. The definition is
+ #ignored for both cases.
BREAKDEF = true
+
+ #When compiling original QuakeWorld QC there are instances where
+ #code overwrites constants. This is considered an error, however
+ #for QuakeWorld to compile it needs to be treated as a warning
+ #instead, as such this warning only works when -std=qcc.
+
+ CONST_OVERWRITE = true
+
[optimizations]
#Some general peephole optimizations. For instance the code `a = b
#+ c` typically generates 2 instructions, an ADD and a STORE. This
LOCAL_TEMPS = true
-
+
#Causes temporary values which do not need to be backed up on a
#CALL to not be stored in the function's locals-area. With this, a
#CALL to a function may need to back up fewer values and thus exe‐
opts_set(opts.warn, WARN_UNINITIALIZED_CONSTANT, true);
opts_set(opts.warn, WARN_DEPRECATED, true);
opts_set(opts.warn, WARN_PARENTHESIS, true);
+ opts_set(opts.warn, WARN_CONST_OVERWRITE, true);
/* flags */
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
GMQCC_DEFINE_FLAG(PARENTHESIS)
GMQCC_DEFINE_FLAG(UNSAFE_TYPES)
GMQCC_DEFINE_FLAG(BREAKDEF)
+ GMQCC_DEFINE_FLAG(CONST_OVERWRITE)
#endif
#ifdef GMQCC_TYPE_OPTIMIZATIONS
if (ast_istype(expr, ast_value)) {
ast_value *val = (ast_value*)expr;
if (val->cvq == CV_CONST) {
- if (val->name[0] == '#')
+ if (val->name[0] == '#') {
compile_error(ctx, "invalid assignment to a literal constant");
- else
+ return false;
+ }
+ /*
+ * To work around quakeworld we must elide the error and make it
+ * a warning instead.
+ */
+ if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_QCC)
compile_error(ctx, "assignment to constant `%s`", val->name);
+ else
+ (void)!compile_warning(ctx, WARN_CONST_OVERWRITE, "assignment to constant `%s`", val->name);
return false;
}
}