ref: 28473d314a98e89397c804b9ed6d9e4b3f39814c
parent: 35f7340dc91260d5a310a6f4a8b024834b113fb5
author: ISSOtm <eldredhabert0@gmail.com>
date: Wed Feb 5 08:20:51 EST 2020
Make implicit truncation a warning
--- a/include/asm/warning.h
+++ b/include/asm/warning.h
@@ -21,6 +21,7 @@
WARNING_SHIFT,
WARNING_USER,
WARNING_SHIFT_AMOUNT,
+ WARNING_TRUNCATION,
NB_WARNINGS,
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1190,7 +1190,7 @@
const_8bit : relocconst
{
if( (!rpn_isReloc(&$1)) && (($1.nVal < -128) || ($1.nVal > 255)) )
- yyerror("Expression must be 8-bit");
+ warning(WARNING_TRUNCATION, "Expression must be 8-bit");
$$ = $1;
}
;
@@ -1198,7 +1198,7 @@
const_16bit : relocconst
{
if ((!rpn_isReloc(&$1)) && (($1.nVal < -32768) || ($1.nVal > 65535)))
- yyerror("Expression must be 16-bit");
+ warning(WARNING_TRUNCATION, "Expression must be 16-bit");
$$ = $1;
}
;
--- a/src/asm/warning.c
+++ b/src/asm/warning.c
@@ -37,6 +37,7 @@
WARNING_DISABLED, /* Shifting undefined behavior */
WARNING_ENABLED, /* User warnings */
WARNING_DISABLED, /* Strange shift amount */
+ WARNING_ENABLED, /* Implicit truncation loses some bits */
};
static enum WarningState warningStates[NB_WARNINGS];
@@ -72,6 +73,7 @@
"shift",
"user",
"shift-amount",
+ "truncation",
/* Meta warnings */
"all",