diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index 3c9effcf0..0fdf2ef85 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -52,6 +52,7 @@ typedef struct { bool commute_float_dot; // allow fp dot product to commute bool assoc_float_add; // allow fp addition to be associative bool assoc_float_mul; // allow fp multiplication to be associative + bool no_double; // double fp type is not supported bool help; } code_options_t; diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index a492fb715..476467687 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -202,7 +202,7 @@ usage (int status) " default for separate compilation mode\n" " -S, --save-temps Do not delete temporary files\n" " -s, --source DIR Look for progs.src in DIR instead of \".\"\n" -" --traditional Traditional QuakeC mode: implies v6only\n" +" --traditional Traditional QuakeC mode: implies target=v6\n" " default when using progs.src\n" " -U, --undefine SYMBOL Undefine preprocessor symbols\n" " -V, --version Output version information and exit\n" @@ -860,6 +860,7 @@ DecodeArgs (int argc, char **argv) } if (options.code.progsversion == PROG_ID_VERSION) { options.code.promote_float = false; + options.code.no_double = true; cpp_define ("__VERSION6__=1"); if (!options_user_set.code.crc) { options.code.crc = true; diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index 0ae58c3aa..065a7fbde 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -584,16 +584,24 @@ parse_number (const rua_tok_t *tok, yyscan_t scanner) fp ? "floating" : type); return 0; } + if (expl == suff_long_double) { + warning (0, "long double treated as double"); + expl = suff_double; + } + if (options.code.no_double && expl == suff_double) { + warning (0, "double treated as float"); + expl = suff_float; + } if (fp) { if (expl == suff_float) { return new_float_expr (fvalue); } else { - if (expl == suff_long_double) { - warning (0, "long double treated as double"); - expl = suff_double; + if (options.code.no_double) { + return new_float_expr (fvalue); + } else { + return new_double_expr (fvalue, expl == suff_implicit); } - return new_double_expr (fvalue, expl == suff_implicit); } } else { if (expl == suff_unsigned) { @@ -696,6 +704,14 @@ parse_vector (const rua_tok_t *tok, yyscan_t scanner) fp ? "floating" : "integer"); return 0; } + if (expl == suff_long_double) { + warning (0, "long double treated as double"); + expl = suff_double; + } + if (options.code.no_double && expl == suff_double) { + warning (0, "double treated as float"); + expl = suff_float; + } union { pr_float_t f[4]; pr_int_t i[4]; @@ -704,10 +720,6 @@ parse_vector (const rua_tok_t *tok, yyscan_t scanner) pr_type_t t[PR_SIZEOF (lvec4)]; } data; const type_t *type = nullptr; - if (expl == suff_long_double) { - warning (0, "long double treated as double"); - expl = suff_double; - } if (expl == suff_float) { for (int i = 0; i < width; i++) { auto c = components[i];