Added warning about unusual number of digits in binary literals,

and a CLI switch to disable that warning.


git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@257 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-06-22 20:32:38 +00:00
parent 9f5ac5b212
commit aa51fde056
6 changed files with 19 additions and 1 deletions

View File

@ -56,6 +56,12 @@ Hex literal without any digits.
A special literal was started, but then no digits followed. Expect
this to become an error in future!
Binary literal with strange number of digits.
This warning is given if the number of digits in a binary literal
is not a multiple of four. This is useful when you meant to write
%#....... but actually wrote %#........ by mistake. See? :P
You can disable this warning using the CLI switch "-Wno-bin-len".
Bug in ACME, code follows
A situation has been encountered implying there is a bug in ACME.
See the last section in this file.

View File

@ -283,6 +283,9 @@ Available options are:
same time enables warnings about the _new_ "!for" syntax.
Internally, this does exactly the same as what happens
when the "--dialect 0.94.8" CLI switch is used...
-Wno-bin-len
Do not complain about unusual number of digits in a binary
literal.
-Wtype-mismatch
Enables type checking system (warns about wrong types).
@ -398,7 +401,7 @@ Examples Notes
$d011 hexadecimal values are indicated by either a
0xffd2 leading "$" or a leading "0x".
&1701 an octal value, indicated by "&"
%010010 binary values are indicated by either a leading "%"
%1010 binary values are indicated by either a leading "%"
%....#... or a leading "0b". In binary values, you can
0b01100110 substitute the characters "0" and "1" by "." and
"#" respectively. This way the values are much

View File

@ -70,6 +70,7 @@ static const char arg_vicelabels[] = "VICE labels filename";
// options for "-W"
#define OPTIONWNO_LABEL_INDENT "no-label-indent"
#define OPTIONWNO_OLD_FOR "no-old-for"
#define OPTIONWNO_BIN_LEN "no-bin-len"
#define OPTIONWTYPE_MISMATCH "type-mismatch"
@ -141,6 +142,7 @@ static void show_help_and_exit(void)
// TODO: replace these:
" -W" OPTIONWNO_LABEL_INDENT " suppress warnings about indented labels\n"
" -W" OPTIONWNO_OLD_FOR " suppress warnings about old \"!for\" syntax\n"
" -W" OPTIONWNO_BIN_LEN " suppress warnings about lengths of binary literals\n"
" -W" OPTIONWTYPE_MISMATCH " enable type checking (warn about type mismatch)\n"
// with this line and add a separate function:
//" -W show warning level options\n"
@ -606,6 +608,9 @@ static char short_option(const char *argument)
} else if (strcmp(argument + 1, OPTIONWNO_OLD_FOR) == 0) {
config.wanted_version = VER_NEWFORSYNTAX - 1;
goto done;
} else if (strcmp(argument + 1, OPTIONWNO_BIN_LEN) == 0) {
config.warn_bin_mask = 0;
goto done;
} else if (strcmp(argument + 1, OPTIONWTYPE_MISMATCH) == 0) {
config.warn_on_type_mismatch = TRUE;
goto done;

View File

@ -491,6 +491,8 @@ static void parse_binary_literal(void) // Now GotByte = "%" or "b"
}
if (!digits)
Throw_warning("Binary literal without any digits."); // FIXME - make into error!
if (digits & config.warn_bin_mask)
Throw_first_pass_warning("Binary literal with strange number of digits.");
// set force bits
if (config.honor_leading_zeroes) {
if (digits > 8) {

View File

@ -121,6 +121,7 @@ void config_default(struct config *conf)
conf->process_verbosity = 0; // level of additional output
conf->warn_on_indented_labels = TRUE; // warn if indented label is encountered
conf->warn_on_type_mismatch = FALSE; // use type-checking system
conf->warn_bin_mask = 3; // %11 -> warn if not divisible by four
conf->max_errors = MAXERRORS; // errors before giving up
conf->format_msvc = FALSE; // enabled by --msvc
conf->format_color = FALSE; // enabled by --color

View File

@ -80,6 +80,7 @@ struct config {
int process_verbosity; // level of additional output
boolean warn_on_indented_labels; // warn if indented label is encountered
boolean warn_on_type_mismatch; // use type-checking system
int warn_bin_mask; // bitmask for digit counter of binary literals
signed long max_errors; // errors before giving up
boolean format_msvc; // enabled by --msvc
boolean format_color; // enabled by --color