+ GMQCC_DEFINE_FLAG (
+ UNUSED_VARIABLE,
+
+ "Generate a warning about variables which are declared but never"
+ "used. This can be avoided by adding the ‘noref’ keyword in front"
+ "of the variable declaration. Additionally a complete section of"
+ "unreferenced variables can be opened using ‘#pragma noref 1’ and"
+ "closed via ‘#pragma noref 0’."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ USED_UNINITIALIZED,
+
+ "Generate a warning if it is possible that a variable can be used"
+ "without prior initialization. Note that this warning is not nec"
+ "essarily reliable if the initialization happens only under cer"
+ "tain conditions. The other way is not possible: that the warning"
+ "is not generated when uninitialized use is possible."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNKNOWN_CONTROL_SEQUENCE,
+
+ "Generate an error when an unrecognized control sequence in a"
+ "string is used. Meaning: when there's a character after a back-"
+ "slash in a string which has no known meaning."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ EXTENSIONS,
+
+ "Warn when using special extensions which are not part of the"
+ "selected standard."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ FIELD_REDECLARED,
+
+ "Generally QC compilers ignore redeclaration of fields. Here you"
+ "can optionally enable a warning."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ MISSING_RETURN_VALUES,
+
+ "Functions which aren't of type void will warn if it possible to"
+ "reach the end without returning an actual value."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ INVALID_PARAMETER_COUNT,
+
+ "Warn about a function call with an invalid number of parameters."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ LOCAL_SHADOWS,
+
+ "Warn when a locally declared variable shadows variable."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ LOCAL_CONSTANTS,
+
+ " Warn when the initialization of a local variable turns the vari"
+ "able into a constant. This is default behaviour unless"
+ "-finitialized-nonconstants is used."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VOID_VARIABLES,
+
+ "There are only 2 known global variables of type void:"
+ "‘end_sys_globals’ and ‘end_sys_fields’. Any other void-variable"
+ "will warn."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ IMPLICIT_FUNCTION_POINTER,
+
+ "A global function which is not declared with the ‘var’ keyword is"
+ "expected to have an implementing body, or be a builtin. If nei"
+ "ther is the case, it implicitly becomes a function pointer, and a"
+ "warning is generated."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VARIADIC_FUNCTION,
+
+ "Currently there's no way for an in QC implemented function to"
+ "access variadic parameters. If a function with variadic parame"
+ "ters has an implementing body, a warning will be generated."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ FRAME_MACROS,
+
+ "Generate warnings about ‘$frame’ commands, for instance about"
+ "duplicate frame definitions."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ EFFECTLESS_STATEMENT,
+
+ "Warn about statements which have no effect. Any expression which"
+ "does not call a function or assigns a variable."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ END_SYS_FIELDS,
+
+ "The ‘end_sys_fields’ variable is supposed to be a global variable"
+ "of type void. It is also recognized as a field but this will"
+ "generate a warning."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ ASSIGN_FUNCTION_TYPES,
+
+ "Warn when assigning to a function pointer with an unmatching sig"
+ "nature. This usually happens in cases like assigning the null"
+ "function to an entity's .think function pointer."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ CPP,
+
+ "Enable warnings coming from the preprocessor. Like duplicate"
+ "macro declarations. This warning triggers when there's a problem"
+ "with the way the preprocessor has been used."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ MULTIFILE_IF,
+
+ "Warn if there's a preprocessor #if spanning across several files."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DOUBLE_DECLARATION,
+
+ "Warn about multiple declarations of globals. This seems pretty"
+ "common in QC code so you probably do not want this unless you"
+ "want to clean up your code."
+ )
+ GMQCC_DEFINE_FLAG (
+ CONST_VAR,
+
+ "The combination of const and var is not illegal, however differ"
+ "ent compilers may handle them differently. We were told, the"
+ "intention is to create a function-pointer which is not assigna"
+ "ble. This is exactly how we interpret it. However for this"
+ "interpretation the ‘var’ keyword is considered superfluous (and"
+ "philosophically wrong), so it is possible to generate a warning"
+ "about this."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ MULTIBYTE_CHARACTER,
+
+ "Warn about multibyte character constants, they do not work right"
+ "now."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ TERNARY_PRECEDENCE,
+
+ "Warn if a ternary expression which contains a comma operator is"
+ "used without enclosing parenthesis, since this is most likely not"
+ "what you actually want. We recommend the -fcorrect-ternary"
+ "option."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNKNOWN_PRAGMAS,
+
+ "Warn when encountering an unrecognized ‘#pragma’ line."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNREACHABLE_CODE,
+
+ "Warn about unreachable code. That is: code after a return state"
+ "ment, or code after a call to a function marked as 'noreturn'."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DEBUG,
+
+ "Enable some warnings added in order to help debugging in the com"
+ "piler. You won't need this."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNKNOWN_ATTRIBUTE,
+
+ "Warn on an unknown attribute. The warning will inlclude only the"
+ "first token inside the enclosing attribute-brackets. This may"
+ "change when the actual attribute syntax is better defined."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ RESERVED_NAMES,
+
+ "Warn when using reserved names such as ‘nil’."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNINITIALIZED_CONSTANT,
+
+ "Warn about global constants (using the ‘const’ keyword) with no"
+ "assigned value."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ UNINITIALIZED_GLOBAL,
+
+ "Warn about global variables with no initializing value. This is"
+ "off by default, and is added mostly to help find null-values"
+ "which are supposed to be replaced by the untyped 'nil' constant."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DIFFERENT_QUALIFIERS,
+
+ "Warn when a variables is redeclared with a different qualifier."
+ "For example when redeclaring a variable as 'var' which was previ"
+ "ously marked 'const'."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DIFFERENT_ATTRIBUTES,
+
+ "Similar to qualifiers but for attributes like ‘[[noreturn]]’."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DEPRECATED,
+
+ "Warn when a function is marked with the attribute \"[[depre"
+ "cated]]\". This flag enables a warning on calls to functions"
+ "marked as such."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ PARENTHESIS,
+
+ "Warn about possible mistakes caused by missing or wrong parenthe"
+ "sis, like an assignment in an 'if' condition when there's no"
+ "additional set of parens around the assignment."
+ )
+#endif
+
+#ifdef GMQCC_TYPE_OPTIMIZATIONS
+ GMQCC_DEFINE_FLAG (
+ PEEPHOLE, 1,
+
+ "Some general peephole optimizations. For instance the code `a = b\n"
+ "+ c` typically generates 2 instructions, an ADD and a STORE. This\n"
+ "optimization removes the STORE and lets the ADD write directly\n"
+ "into A."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ TAIL_RECURSION, 1,
+
+ "Tail recursive function calls will be turned into loops to avoid\n"
+ "the overhead of the CALL and RETURN instructions."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ OVERLAP_LOCALS, 3,
+
+ "Make all functions which use neither local arrays nor have locals\n"
+ "which are seen as possibly uninitialized use the same local sec‐\n"
+ "tion. This should be pretty safe compared to other compilers\n"
+ "which do not check for uninitialized values properly. The problem\n"
+ "is that there's QC code out there which really doesn't initialize\n"
+ "some values. This is fine as long as this kind of optimization\n"
+ "isn't used, but also, only as long as the functions cannot be\n"
+ "called in a recursive manner. Since it's hard to know whether or\n"
+ "not an array is actually fully initialized, especially when ini‐\n"
+ "tializing it via a loop, we assume functions with arrays to be\n"
+ "too dangerous for this optimization."
+ )
+
+
+ GMQCC_DEFINE_FLAG (
+ LOCAL_TEMPS, 3,
+
+ "This promotes locally declared variables to \"temps\". Meaning when\n"
+ "a temporary result of an operation has to be stored somewhere, a\n"
+ "local variable which is not 'alive' at that point can be used to\n"
+ "keep the result. This can reduce the size of the global section.\n"
+ "This will not have declared variables overlap, even if it was\n"
+ "possible."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ GLOBAL_TEMPS, 3,
+
+ "Causes temporary values which do not need to be backed up on a\n"
+ "CALL to not be stored in the function's locals-area. With this, a\n"
+ "CALL to a function may need to back up fewer values and thus exe‐\n"
+ "cute faster."
+ )
+
+
+ GMQCC_DEFINE_FLAG (
+ STRIP_CONSTANT_NAMES, 1,
+
+ "Don't generate defs for immediate values or even declared con‐\n"
+ "stants. Meaning variables which are implicitly constant or qual‐\n"
+ "ified as such using the 'const' keyword."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ OVERLAP_STRINGS, 2,
+
+ "Aggressively reuse strings in the string section. When a string\n"
+ "should be added which is the trailing substring of an already\n"
+ "existing string, the existing string's tail will be returned\n"
+ "instead of the new string being added.\n\n"
+ "For example the following code will only generate 1 string:\n\n"
+ " print(\"Hell you!\\n\");\n"
+ " print(\"you!\n\"); // trailing substring of \"Hello you!\\n\"\n\n"
+ "There's however one limitation. Strings are still processed in\n"
+ "order, so if the above print statements were reversed, this opti‐\n"
+ "mization would not happen."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ CALL_STORES, 3,
+
+ "By default, all parameters of a CALL are copied into the parame‐\n"
+ "ter-globals right before the CALL instructions. This is the easi‐\n"
+ "est and safest way to translate calls, but also adds a lot of\n"
+ "unnecessary copying and unnecessary temporary values. This opti‐\n"
+ "mization makes operations which are used as a parameter evaluate\n"
+ "directly into the parameter-global if that is possible, which is\n"
+ "when there's no other CALL instruction in between."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VOID_RETURN, 1,
+
+ "Usually an empty RETURN instruction is added to the end of a void\n"
+ "typed function. However, additionally after every function a DONE\n"
+ "instruction is added for several reasons. (For example the qcvm's\n"
+ "disassemble switch uses it to know when the function ends.). This\n"
+ "optimization replaces that last RETURN with DONE rather than\n"
+ "adding the DONE additionally."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VECTOR_COMPONENTS, 1,
+
+ "Because traditional QC code doesn't allow you to access individ‐\n"
+ "ual vector components of a computed vector without storing it in\n"
+ "a local first, sometimes people multiply it by a constant like\n"
+ "‘'0 1 0'’ to get, in this case, the y component of a vector. This\n"
+ "optimization will turn such a multiplication into a direct compo‐\n"
+ "nent access. If the factor is anything other than 1, a float-mul‐\n"
+ "tiplication will be added, which is still faster than a vector"
+ "multiplication."
+ )