[PATCH 12/17] fix expansion of initializer (mismatching type)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, the expansion of constant initializers is done
whenever the offset in the initializer match the one
being expanded.

However, it's not correct to do this expansion of an
integer with the initializer for a float and vice-versa.

Fix this by adding the corresponding tests to the other
tests of the value.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 expand.c                                   | 4 ++++
 validation/expand/constant-union-flt2int.c | 1 -
 validation/expand/constant-union-int2flt.c | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/expand.c b/expand.c
index 04b072c53b5a..9ab259b13a82 100644
--- a/expand.c
+++ b/expand.c
@@ -694,6 +694,8 @@ static int expand_dereference(struct expression *expr)
 			if (ctype->bit_size != value->ctype->bit_size)
 				return UNSAFE;
 			if (value->type == EXPR_VALUE) {
+				if (!is_integral_type(ctype))
+					return UNSAFE;
 				if (is_bitfield_type(value->ctype))
 					return UNSAFE;
 				expr->type = EXPR_VALUE;
@@ -701,6 +703,8 @@ static int expand_dereference(struct expression *expr)
 				expr->taint = 0;
 				return 0;
 			} else if (value->type == EXPR_FVALUE) {
+				if (!is_float_type(ctype))
+					return UNSAFE;
 				expr->type = EXPR_FVALUE;
 				expr->fvalue = value->fvalue;
 				return 0;
diff --git a/validation/expand/constant-union-flt2int.c b/validation/expand/constant-union-flt2int.c
index 1c8f480b6c81..5e25b592b204 100644
--- a/validation/expand/constant-union-flt2int.c
+++ b/validation/expand/constant-union-flt2int.c
@@ -13,7 +13,6 @@ static int foo(void)
  * check-name: constant-union-float-to-int
  * check description: must not infer the int value from the float
  * check-command: test-linearize -fdump-ir $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-pattern(1): setfval\\.
diff --git a/validation/expand/constant-union-int2flt.c b/validation/expand/constant-union-int2flt.c
index ff0a642ad67d..16ce1c6f3fe3 100644
--- a/validation/expand/constant-union-int2flt.c
+++ b/validation/expand/constant-union-int2flt.c
@@ -13,7 +13,6 @@ static float foo(void)
  * check-name: constant-union-int-to-float
  * check description: must not infer the float value from the int
  * check-command: test-linearize -fdump-ir $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-pattern(1): load\\.
-- 
2.24.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux