]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - main.c
gitignore: be more clever
[xonotic/gmqcc.git] / main.c
diff --git a/main.c b/main.c
index 244d57000c6afae7f0473e3e6bd3eb41b8d2f49a..2b055d2210f35bf59d556053f366e27c7c12e3d8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012
+ * Copyright (C) 2012, 2013
  *     Dale Weiler
  *     Wolfgang Bumiller
  *
@@ -51,6 +51,11 @@ static void version() {
         __DATE__,
         __TIME__
     );
+#ifdef GMQCC_GITINFO
+    con_out("git build: %s\n", GMQCC_GITINFO);
+#elif defined(GMQCC_VERION_TYPE_DEVEL)
+    con_out("development build\n");
+#endif
 }
 
 static int usage() {
@@ -158,11 +163,15 @@ static bool options_parse(int argc, char **argv) {
             if (options_long_gcc("std", &argc, &argv, &argarg)) {
                 if (!strcmp(argarg, "gmqcc") || !strcmp(argarg, "default")) {
 
-                    opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
-                    opts_set(opts.flags, CORRECT_LOGIC,        true);
-                    opts_set(opts.flags, FALSE_EMPTY_STRINGS,  false);
-                    opts_set(opts.flags, TRUE_EMPTY_STRINGS,   true);
-                    opts_set(opts.flags, LOOP_LABELS,          true);
+                    opts_set(opts.flags, ADJUST_VECTOR_FIELDS,          true);
+                    opts_set(opts.flags, CORRECT_LOGIC,                 true);
+                    opts_set(opts.flags, FALSE_EMPTY_STRINGS,           false);
+                    opts_set(opts.flags, TRUE_EMPTY_STRINGS,            true);
+                    opts_set(opts.flags, LOOP_LABELS,                   true);
+                    opts_set(opts.flags, TRANSLATABLE_STRINGS,          true);
+                    opts_set(opts.flags, INITIALIZED_NONCONSTANTS,      true);
+                    opts_set(opts.werror, WARN_INVALID_PARAMETER_COUNT, true);
+                    opts_set(opts.werror, WARN_MISSING_RETURN_VALUES,   true);
                     opts.standard = COMPILER_GMQCC;
 
                 } else if (!strcmp(argarg, "qcc")) {
@@ -177,8 +186,8 @@ static bool options_parse(int argc, char **argv) {
                     opts_set(opts.flags, TRANSLATABLE_STRINGS,     true);
                     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,     false);
                     opts_set(opts.flags, ASSIGN_FUNCTION_TYPES,    true);
-                    opts_set(opts.warn, WARN_TERNARY_PRECEDENCE,   true);
                     opts_set(opts.flags, CORRECT_TERNARY,          false);
+                    opts_set(opts.warn, WARN_TERNARY_PRECEDENCE,   true);
                     opts.standard = COMPILER_FTEQCC;
 
                 } else if (!strcmp(argarg, "qccx")) {
@@ -339,8 +348,10 @@ static bool options_parse(int argc, char **argv) {
                     else if (!strcmp(argv[0]+2, "ERROR") ||
                              !strcmp(argv[0]+2, "ERROR_ALL"))
                     {
+                        opts_backup_non_Werror_all();
                         for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
                             opts.werror[itr] = 0xFFFFFFFFL;
+                        opts_restore_non_Werror_all();
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "NONE")) {
@@ -349,8 +360,10 @@ static bool options_parse(int argc, char **argv) {
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "ALL")) {
+                        opts_backup_non_Wall();
                         for (itr = 0; itr < sizeof(opts.warn)/sizeof(opts.warn[0]); ++itr)
                             opts.warn[itr] = 0xFFFFFFFFL;
+                        opts_restore_non_Wall();
                         break;
                     }
                     else if (!strncmp(argv[0]+2, "ERROR_", 6)) {
@@ -452,6 +465,18 @@ static bool options_parse(int argc, char **argv) {
                         opts.quiet = true;
                         break;
                     }
+                    else if (!strcmp(argv[0]+2, "correct")) {
+                        opts.correction = true;
+                        break;
+                    }
+                    else if (!strcmp(argv[0]+2, "no-correct")) {
+                        opts.correction = false;
+                        break;
+                    }
+                    else if (!strcmp(argv[0]+2, "add-info")) {
+                        opts.add_info = true;
+                        break;
+                    }
                     else {
             /* All long options with arguments */
                         if (options_long_witharg("output", &argc, &argv, &argarg)) {
@@ -527,7 +552,7 @@ int main(int argc, char **argv) {
 
     if (OPTS_FLAG(TRUE_EMPTY_STRINGS) && OPTS_FLAG(FALSE_EMPTY_STRINGS)) {
         con_err("-ftrue-empty-strings and -ffalse-empty-strings are mutually exclusive");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* the standard decides which set of operators to use */
@@ -550,7 +575,7 @@ int main(int argc, char **argv) {
                 operators[operator_count-1].id != opid2(':','?'))
             {
                 con_err("internal error: operator precedence table wasn't updated correctly!\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             operators_free = true;
             newops = (oper_info*)mem_a(sizeof(operators[0]) * operator_count);
@@ -567,7 +592,7 @@ int main(int argc, char **argv) {
             con_out("Flag %s = %i\n",    opts_flag_list[itr].name, OPTS_FLAG(itr));
         for (itr = 0; itr < COUNT_WARNINGS; ++itr)
             con_out("Warning %s = %i\n", opts_warn_list[itr].name, OPTS_WARN(itr));
-        
+
         con_out("output             = %s\n", opts.output);
         con_out("optimization level = %d\n", opts.O);
         con_out("standard           = %i\n", opts.standard);