[qfcc] Add pragma to control optimization

And force a couple of tests to be built with optimization. I'll probably
add it to most, if not all, but for now I'm clearing up tests as I go.
This commit is contained in:
Bill Currie 2022-02-01 13:24:27 +09:00
parent f714b6fbea
commit 64c8c02eac
3 changed files with 22 additions and 0 deletions

View file

@ -125,6 +125,24 @@ set_warn (pragma_arg_t *args)
}
}
static void
set_optimize (pragma_arg_t *args)
{
if (!args) {
warning (0, "missing warn flag");
return;
}
const char *flag = args->arg;
if (!strcmp (flag, "on") || !strcmp (flag, "!off")) {
options.code.optimize = true;
} else if (!strcmp (flag, "!on") || !strcmp (flag, "off")) {
options.code.optimize = false;
}
if (args->next) {
warning (0, "pragma optimize: ignoring extra arguments");
}
}
void
pragma_process ()
{
@ -143,6 +161,8 @@ pragma_process ()
set_bug (pragma_args->next);
} else if (!strcmp (id, "warn")) {
set_warn (pragma_args->next);
} else if (!strcmp (id, "optimize")) {
set_optimize (pragma_args->next);
} else {
warning (0, "unknown pragma: '%s'", id);
}

View file

@ -1,4 +1,5 @@
#pragma warn error
#pragma optimize on
@interface Object
{

View file

@ -1,3 +1,4 @@
#pragma optimize on
#include "test-harness.h"
int counter;