mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-12-18 00:11:06 +00:00
handling TOKEN_CHARCONST - -Wmultibyte-character
This commit is contained in:
parent
2234090398
commit
797ceb9e04
4 changed files with 12 additions and 1 deletions
8
lexer.c
8
lexer.c
|
@ -1290,6 +1290,14 @@ int lex_do(lex_file *lex)
|
||||||
{
|
{
|
||||||
lex->tok.ttype = TOKEN_VECTORCONST;
|
lex->tok.ttype = TOKEN_VECTORCONST;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!lex->flags.preprocessing && strlen(lex->tok.value) > 1) {
|
||||||
|
if (lexwarn(lex, WARN_MULTIBYTE_CHARACTER, "multibyte character: `%s`", lex->tok.value))
|
||||||
|
return (lex->tok.ttype = TOKEN_ERROR);
|
||||||
|
}
|
||||||
|
lex->tok.constval.i = lex->tok.value[0];
|
||||||
|
}
|
||||||
|
|
||||||
return lex->tok.ttype;
|
return lex->tok.ttype;
|
||||||
}
|
}
|
||||||
|
|
2
main.c
2
main.c
|
@ -473,6 +473,8 @@ int main(int argc, char **argv) {
|
||||||
options_set(opts_warn, WARN_PREPROCESSOR, true);
|
options_set(opts_warn, WARN_PREPROCESSOR, true);
|
||||||
options_set(opts_warn, WARN_MULTIFILE_IF, true);
|
options_set(opts_warn, WARN_MULTIFILE_IF, true);
|
||||||
options_set(opts_warn, WARN_DOUBLE_DECLARATION, true);
|
options_set(opts_warn, WARN_DOUBLE_DECLARATION, true);
|
||||||
|
options_set(opts_warn, WARN_CONST_VAR, true);
|
||||||
|
options_set(opts_warn, WARN_MULTIBYTE_CHARACTER, true);
|
||||||
|
|
||||||
options_set(opts_flags, ADJUST_VECTOR_FIELDS, true);
|
options_set(opts_flags, ADJUST_VECTOR_FIELDS, true);
|
||||||
options_set(opts_flags, FTEPP, false);
|
options_set(opts_flags, FTEPP, false);
|
||||||
|
|
1
opts.def
1
opts.def
|
@ -62,6 +62,7 @@
|
||||||
GMQCC_DEFINE_FLAG(MULTIFILE_IF)
|
GMQCC_DEFINE_FLAG(MULTIFILE_IF)
|
||||||
GMQCC_DEFINE_FLAG(DOUBLE_DECLARATION)
|
GMQCC_DEFINE_FLAG(DOUBLE_DECLARATION)
|
||||||
GMQCC_DEFINE_FLAG(CONST_VAR)
|
GMQCC_DEFINE_FLAG(CONST_VAR)
|
||||||
|
GMQCC_DEFINE_FLAG(MULTIBYTE_CHARACTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* some cleanup so we don't have to */
|
/* some cleanup so we don't have to */
|
||||||
|
|
2
parser.c
2
parser.c
|
@ -1428,7 +1428,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
|
||||||
vec_push(sy.out, syexp(parser_ctx(parser), (ast_expression*)val));
|
vec_push(sy.out, syexp(parser_ctx(parser), (ast_expression*)val));
|
||||||
DEBUGSHUNTDO(con_out("push %g\n", parser_token(parser)->constval.f));
|
DEBUGSHUNTDO(con_out("push %g\n", parser_token(parser)->constval.f));
|
||||||
}
|
}
|
||||||
else if (parser->tok == TOKEN_INTCONST) {
|
else if (parser->tok == TOKEN_INTCONST || parser->tok == TOKEN_CHARCONST) {
|
||||||
ast_value *val;
|
ast_value *val;
|
||||||
if (wantop) {
|
if (wantop) {
|
||||||
parseerror(parser, "expected operator or end of statement, got constant");
|
parseerror(parser, "expected operator or end of statement, got constant");
|
||||||
|
|
Loading…
Reference in a new issue