1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Fix bit-field truncation warning message

Fix copy & paste bug with warning message.

struct X {
      signed int a : 3;
};
struct X g = { 5 };

Before:
s.c(4): Warning: Implicit truncation from 'int' to 'int : 3' in bit-field
initializer changes value from 5 to 5

After:
s.c(4): Warning: Implicit truncation from 'int' to 'int : 3' in bit-field
initializer changes value from 5 to -3

Fixes #1268
This commit is contained in:
Jesse Rosenstock 2020-09-26 08:36:17 +02:00 committed by greg-king5
parent 34177d9edd
commit d0089aef95

View File

@ -2567,9 +2567,9 @@ static unsigned ParseStructInit (Type* T, int* Braces, int AllowFlexibleMembers)
long RestoredVal = asr_l(asl_l (Val, ShiftBits), ShiftBits);
if (ED.IVal != RestoredVal) {
Warning ("Implicit truncation from '%s' to '%s : %u' in bit-field initializer "
"changes value from %ld to %d",
"changes value from %ld to %ld",
GetFullTypeName (ED.Type), GetFullTypeName (Entry->Type),
Entry->V.B.BitWidth, ED.IVal, Val);
Entry->V.B.BitWidth, ED.IVal, RestoredVal);
}
}