/*
- * Copyright (C) 2012
+ * Copyright (C) 2012, 2013
* Wolfgang Bumiller
* Dale Weiler
*
static void opts_setdefault() {
memset(&opts, 0, sizeof(opts_cmd_t));
-
+ opts.correction = true;
+
/* warnings */
opts_set(opts.warn, WARN_UNUSED_VARIABLE, true);
opts_set(opts.warn, WARN_USED_UNINITIALIZED, true);
opts_set(opts.warn, WARN_EXTENSIONS, true);
opts_set(opts.warn, WARN_FIELD_REDECLARED, true);
opts_set(opts.warn, WARN_MISSING_RETURN_VALUES, true);
- opts_set(opts.warn, WARN_TOO_FEW_PARAMETERS, true);
+ opts_set(opts.warn, WARN_INVALID_PARAMETER_COUNT, true);
opts_set(opts.warn, WARN_LOCAL_SHADOWS, false);
opts_set(opts.warn, WARN_LOCAL_CONSTANTS, true);
opts_set(opts.warn, WARN_VOID_VARIABLES, true);
opts_set(opts.warn, WARN_UNREACHABLE_CODE, true);
opts_set(opts.warn, WARN_CPP, true);
opts_set(opts.warn, WARN_UNKNOWN_ATTRIBUTE, true);
+ opts_set(opts.warn, WARN_RESERVED_NAMES, true);
+ opts_set(opts.warn, WARN_UNINITIALIZED_CONSTANT, true);
+ opts_set(opts.warn, WARN_UNINITIALIZED_GLOBAL, false);
+ opts_set(opts.warn, WARN_DEPRECATED, true);
+ opts_set(opts.warn, WARN_PARENTHESIS, true);
/* flags */
opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
opts_set(opts.flags, FTEPP, false);
+ opts_set(opts.flags, FTEPP_PREDEFS, false);
opts_set(opts.flags, CORRECT_TERNARY, true);
+ opts_set(opts.flags, BAIL_ON_WERROR, true);
+}
+
+void opts_backup_non_Wall() {
+ size_t i;
+ for (i = 0; i <= WARN_DEBUG; ++i)
+ opts_set(opts.warn_backup, i, OPTS_WARN(i));
+}
+
+void opts_restore_non_Wall() {
+ size_t i;
+ for (i = 0; i <= WARN_DEBUG; ++i)
+ opts_set(opts.warn, i, OPTS_GENERIC(opts.warn_backup, i));
+}
+
+void opts_backup_non_Werror_all() {
+ size_t i;
+ for (i = 0; i <= WARN_DEBUG; ++i)
+ opts_set(opts.werror_backup, i, OPTS_WERROR(i));
+}
+
+void opts_restore_non_Werror_all() {
+ size_t i;
+ for (i = 0; i <= WARN_DEBUG; ++i)
+ opts_set(opts.werror, i, OPTS_GENERIC(opts.werror_backup, i));
}
void opts_init(const char *output, int standard, size_t arraysize) {
opts_setdefault();
-
+
opts.output = output;
- opts.standard = standard;
+ opts.standard = (opts_std_t)standard; /* C++ ... y u no like me? */
opts.max_array_size = arraysize;
}
for (i = 0; i < listsize; ++i) {
if (!strcmp(name, list[i].name)) {
longbit lb = list[i].bit;
-#if 0
+#if 1
if (on)
flags[lb.idx] |= (1<<(lb.bit));
else
}
void opts_set(uint32_t *flags, size_t idx, bool on) {
- longbit lb = LONGBIT(idx);
-#if 0
+ longbit lb;
+ LONGBIT_SET(lb, idx);
+#if 1
if (on)
flags[lb.idx] |= (1<<(lb.bit));
else
char *read_name;
char *read_value;
- while (util_getline(&line, &linesize, filehandle) != EOF) {
+ while (file_getline(&line, &linesize, filehandle) != EOF) {
parse_beg = line;
/* handle BOM */
}
#include "opts.def"
+ /* Werror-individuals */
+ #define GMQCC_TYPE_WARNS
+ #define GMQCC_DEFINE_FLAG(X) \
+ if (!strcmp(section, "errors") && !strcmp(name, #X)) { \
+ opts_set(opts.werror, WARN_##X, opts_ini_bool(value)); \
+ found = true; \
+ }
+ #include "opts.def"
+
/* optimizations */
#define GMQCC_TYPE_OPTIMIZATIONS
#define GMQCC_DEFINE_FLAG(X,Y) \
if (!file) {
/* try ini */
- if (!(ini = fopen((file = "gmqcc.ini"), "r")))
+ if (!(ini = file_open((file = "gmqcc.ini"), "r")))
/* try cfg */
- if (!(ini = fopen((file = "gmqcc.cfg"), "r")))
+ if (!(ini = file_open((file = "gmqcc.cfg"), "r")))
return;
- } else if (!(ini = fopen(file, "r")))
+ } else if (!(ini = file_open(file, "r")))
return;
con_out("found ini file `%s`\n", file);
vec_free(error);
}
- fclose(ini);
+ file_close(ini);
}