]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Implemented -f[no]enhanced-diagnostics, to enable/disable the usage of enhanced diagn...
authorDale Weiler <killfieldengine@gmail.com>
Fri, 4 Jan 2013 12:07:42 +0000 (12:07 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 4 Jan 2013 12:07:42 +0000 (12:07 +0000)
gmqcc.ini.example
opts.c
opts.def
parser.c

index 2c63fcd44e0a1f14205e52b9703aec6331a86834..6f8f923b34d968d6045922d479fa27df7c05b8b4 100644 (file)
     # variables with the name 'nil' to be declared.
     PREMISSIVE                   = false
 
+    # Enable enhanced diagnostic messages. i.e provides a "did you mean"
+    # <ident> when you accidently typo. Amongst others
+    ENHANCED_DIAGNOSTICS         = true
+
 # These are all the warnings, usually present via the -W prefix from
 # the command line.
 [warnings]
diff --git a/opts.c b/opts.c
index c5c358d5e1dc8417a1428de24a84dde23af0d653..548381a3be634385b989803c63d8e46e0d2ca4fd 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -65,6 +65,7 @@ static void opts_setdefault() {
     opts_set(opts.flags, FTEPP_PREDEFS,                  false);
     opts_set(opts.flags, CORRECT_TERNARY,                true);
     opts_set(opts.flags, BAIL_ON_WERROR,                 true);
+    opts_set(opts.flags, ENHANCED_DIAGNOSTICS,           true);
 }
 
 void opts_init(const char *output, int standard, size_t arraysize) {
index 41ff6d49432c8963197bc7bc196cbde19be5b832..22e2dab4b984c912d7dfb7805e5b21a8f30d8a1c 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -48,6 +48,7 @@
     GMQCC_DEFINE_FLAG(LOOP_LABELS)
     GMQCC_DEFINE_FLAG(UNTYPED_NIL)
     GMQCC_DEFINE_FLAG(PERMISSIVE)
+    GMQCC_DEFINE_FLAG(ENHANCED_DIAGNOSTICS)
 #endif
 
 /* warning flags */
index 6c507d1aeb4a24a83ac50b5778cc55c727a93777..e93c7928e76375d189ff0dd3debad579be76e300 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1642,22 +1642,23 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
                      * We should also consider adding correction tables for
                      * other things as well.
                      */
-                    for (i = 0; i < vec_size(parser->correct_variables); i++) {
-                        correct = correct_str(parser->correct_variables[i], parser_tokval(parser));
-                        if (strcmp(correct, parser_tokval(parser))) {
-                            break;
-                        } else if (correct) {
-                            mem_d(correct);
+                    if (OPTS_FLAG(ENHANCED_DIAGNOSTICS)) {
+                        for (i = 0; i < vec_size(parser->correct_variables); i++) {
+                            correct = correct_str(parser->correct_variables[i], parser_tokval(parser));
+                            if (strcmp(correct, parser_tokval(parser))) {
+                                break;
+                            } else if (correct) {
+                                mem_d(correct);
+                            }
                         }
-                    }
 
-                    if (correct) {
-                        parseerror(parser, "unexpected ident: %s (did you mean %s?)", parser_tokval(parser), correct);
-                        mem_d(correct);
-                    } else {
-                        parseerror(parser, "unexpected ident: %s", parser_tokval(parser));
+                        if (correct) {
+                            parseerror(parser, "unexpected ident: %s (did you mean %s?)", parser_tokval(parser), correct);
+                            mem_d(correct);
+                            goto onerr;
+                        }
                     }
-
+                    parseerror(parser, "unexpected ident: %s", parser_tokval(parser));
                     goto onerr;
                 }
             }