void opts_setoptimlevel(unsigned int);
void opts_ini_init (const char *);
+/* Saner flag handling */
+void opts_backup_non_Wall();
+void opts_restore_non_Wall();
+void opts_backup_non_Werror_all();
+void opts_restore_non_Werror_all();
+
enum {
# define GMQCC_TYPE_FLAGS
# define GMQCC_DEFINE_FLAG(X) X,
bool pp_only; /* -E */
size_t max_array_size; /* --max-array= */
- uint32_t flags [1 + (COUNT_FLAGS / 32)];
- uint32_t warn [1 + (COUNT_WARNINGS / 32)];
- uint32_t werror [1 + (COUNT_WARNINGS / 32)];
- uint32_t optimization[1 + (COUNT_OPTIMIZATIONS / 32)];
+ uint32_t flags [1 + (COUNT_FLAGS / 32)];
+ uint32_t warn [1 + (COUNT_WARNINGS / 32)];
+ uint32_t werror [1 + (COUNT_WARNINGS / 32)];
+ uint32_t warn_backup [1 + (COUNT_WARNINGS / 32)];
+ uint32_t werror_backup[1 + (COUNT_WARNINGS / 32)];
+ uint32_t optimization [1 + (COUNT_OPTIMIZATIONS / 32)];
} opts_cmd_t;
extern opts_cmd_t opts;
-#define OPTS_FLAG(i) (!! (opts.flags [(i)/32] & (1<< ((i)%32))))
-#define OPTS_WARN(i) (!! (opts.warn [(i)/32] & (1<< ((i)%32))))
-#define OPTS_WERROR(i) (!! (opts.werror [(i)/32] & (1<< ((i)%32))))
-#define OPTS_OPTIMIZATION(i) (!! (opts.optimization[(i)/32] & (1<< ((i)%32))))
+#define OPTS_GENERIC(f,i) (!! (((f)[(i)/32]) & (1<< ((i)%32))))
+#define OPTS_FLAG(i) OPTS_GENERIC(opts.flags, (i))
+#define OPTS_WARN(i) OPTS_GENERIC(opts.warn, (i))
+#define OPTS_WERROR(i) OPTS_GENERIC(opts.werror, (i))
+#define OPTS_OPTIMIZATION(i) OPTS_GENERIC(opts.optimization, (i))
#endif
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")) {
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)) {
opts_set(opts.flags, ENHANCED_DIAGNOSTICS, 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 = (opts_std_t)standard; /* C++ ... y u no like me? */
opts.max_array_size = arraysize;
/* warning flags */
#ifdef GMQCC_TYPE_WARNS
+ GMQCC_DEFINE_FLAG(UNINITIALIZED_GLOBAL)
GMQCC_DEFINE_FLAG(DEBUG)
GMQCC_DEFINE_FLAG(UNUSED_VARIABLE)
GMQCC_DEFINE_FLAG(USED_UNINITIALIZED)
GMQCC_DEFINE_FLAG(UNKNOWN_ATTRIBUTE)
GMQCC_DEFINE_FLAG(RESERVED_NAMES)
GMQCC_DEFINE_FLAG(UNINITIALIZED_CONSTANT)
- GMQCC_DEFINE_FLAG(UNINITIALIZED_GLOBAL)
GMQCC_DEFINE_FLAG(DIFFERENT_QUALIFIERS)
GMQCC_DEFINE_FLAG(DIFFERENT_ATTRIBUTES)
GMQCC_DEFINE_FLAG(DEPRECATED)