diff --git a/tools/qfcc/source/pragma.c b/tools/qfcc/source/pragma.c index 9e3a393aa..fb72130f4 100644 --- a/tools/qfcc/source/pragma.c +++ b/tools/qfcc/source/pragma.c @@ -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); } diff --git a/tools/qfcc/test/dealloc-warn3.r b/tools/qfcc/test/dealloc-warn3.r index 32427e2ff..a8dd2d2b4 100644 --- a/tools/qfcc/test/dealloc-warn3.r +++ b/tools/qfcc/test/dealloc-warn3.r @@ -1,4 +1,5 @@ #pragma warn error +#pragma optimize on @interface Object { diff --git a/tools/qfcc/test/return-postop.r b/tools/qfcc/test/return-postop.r index 5ec27f4a1..bdf244f98 100644 --- a/tools/qfcc/test/return-postop.r +++ b/tools/qfcc/test/return-postop.r @@ -1,3 +1,4 @@ +#pragma optimize on #include "test-harness.h" int counter;