From c0f2b69bef0c47cdbcbfa9b2291b68768c294529 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Sun, 19 Jul 2020 22:59:44 +0200 Subject: [PATCH] Add test case for sign extending < 1 byte --- test/todo/bug1095.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/todo/bug1095.c b/test/todo/bug1095.c index a00a10585..0803c2d1c 100644 --- a/test/todo/bug1095.c +++ b/test/todo/bug1095.c @@ -30,7 +30,8 @@ static struct signed_ints { signed int a : 3; signed int b : 3; signed int c : 3; -} si = {-4, -1, 3}; + signed int d : 10; +} si = {-4, -1, 3, -500}; static void test_signed_bitfield(void) { @@ -61,9 +62,19 @@ static void test_signed_bitfield(void) failures++; } + if (si.d >= 0) { + printf("Got si.d = %d, expected negative.\n", si.d); + failures++; + } + if (si.d != -500) { + printf("Got si.d = %d, expected -500.\n", si.d); + failures++; + } + si.a = -3; si.b = 1; si.c = -2; + si.d = 500; if (si.a >= 0) { printf("Got si.a = %d, expected negative.\n", si.a); @@ -91,6 +102,15 @@ static void test_signed_bitfield(void) printf("Got si.c = %d, expected -2.\n", si.c); failures++; } + + if (si.d <= 0) { + printf("Got si.d = %d, expected positive.\n", si.d); + failures++; + } + if (si.d != 500) { + printf("Got si.d = %d, expected 500.\n", si.d); + failures++; + } } int main(void)