Skip to content

Commit 4ddd45b

Browse files
committed
Allow no- as a prefix for disabling warnings and optimizations
1 parent a33eee1 commit 4ddd45b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Version 6.6.2
2-
- Added warnings for constant array indices out of bounds
2+
- Added warning (-Warray-index) for constant array indices out of bounds
3+
- Allow warnings and optimizations to be turned off with a `no-` prefix (so `warn(no-init-vars)` is like `warn(!init-vars)`).
34

45
Version 6.6.1
56
- Changed type of `dat` array in C++ output to `unsigned char`

cmdline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ int ParseOptimizeString(AST *line, const char *str, int *flag_ptr)
560560
if (*buf == '!' || *buf == '~') {
561561
buf++;
562562
notflag = 1;
563+
} else if (buf[0] == 'n' && buf[1] == 'o' && buf[2] == '-') {
564+
buf += 3;
565+
notflag = 1;
563566
} else {
564567
notflag = 0;
565568
}
@@ -639,6 +642,9 @@ int ParseWarnString(AST *line, const char *str, int *flag_ptr)
639642
if (*buf == '!' || *buf == '~') {
640643
buf++;
641644
notflag = 1;
645+
} else if (buf[0] == 'n' && buf[1] == 'o' && buf[2] == '-') {
646+
buf += 3;
647+
notflag = 1;
642648
} else {
643649
notflag = 0;
644650
}

doc/general.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ In BASIC we use the `for` keyword followed by a string giving the warning option
251251
function for "warn(!init-vars)" myfunc()
252252
```
253253

254-
Multiple warnings may be given, separated by commas. To turn a warning off, prefix it with `!` or with `~`. To enable all warnings, use the word `all`.
254+
Multiple warnings may be given, separated by commas. To turn a warning off, prefix it with `!`, `~`, or `no-`. To enable all warnings, use the word `all`.
255255

256-
Thus, a Spin function with `{++opt(!all,hide-members)}` will always be compiled with no warnings except for uninitialized variables.
256+
Thus, a Spin function with `{++opt(!all,hide-members)}` will always be compiled with no warnings except for ones about local variables shadowing object members.
257257

258258
### Warning control on the command line
259259

@@ -304,7 +304,7 @@ In BASIC we use the `for` keyword followed by a string giving the optimization o
304304
function for "opt(!loop-reduce)" myfunc()
305305
```
306306

307-
Multiple options may be given, separated by commas. To turn an option off, prefix it with `!` or with `~`. To enable all options for a particular optimization level, start the string with `0`, `1`, `2`, etc., or with the word `all` to enable all optimizations (regardless of the compiler optimization level chosen).
307+
Multiple options may be given, separated by commas. To turn an option off, prefix it with `!` or `~` or `no-`. To enable all options for a particular optimization level, start the string with `0`, `1`, `2`, etc., or with the word `all` to enable all optimizations (regardless of the compiler optimization level chosen).
308308

309309
Thus, a Spin function with `{++opt(0,peephole)}` will always be compiled with no optimization except peepholes, even when the `-O2` option is given to the compiler.
310310

0 commit comments

Comments
 (0)