[PATCH 09/17] fix addressability marking in evaluate_addressof()

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

 



mark_addressable() is used to track if a symbol has its
address taken but does not take in account the fact that
a symbol can be accessed via one of its subfields.
A failure occurs in case like:
	struct { int a; } s = { 3 };
	...
	def(&s.a);
	return s.a;

where 's' is not marked as being addressable and so the
the initializer will be expanded and the return expression
will always be replaced by 3, while def() can redefine it.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c                            | 2 ++
 validation/eval/addressable-complex.c | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/evaluate.c b/evaluate.c
index d78de2edf1ed..c0281e9b10f2 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1542,6 +1542,8 @@ static int compatible_argument_type(struct expression *expr, struct symbol *targ
 
 static void mark_addressable(struct expression *expr)
 {
+	while (expr->type == EXPR_BINOP && expr->op == '+')
+		expr = expr->left;
 	if (expr->type == EXPR_SYMBOL) {
 		struct symbol *sym = expr->symbol;
 		sym->ctype.modifiers |= MOD_ADDRESSABLE;
diff --git a/validation/eval/addressable-complex.c b/validation/eval/addressable-complex.c
index 62ab59f04cf9..e3d4aca49088 100644
--- a/validation/eval/addressable-complex.c
+++ b/validation/eval/addressable-complex.c
@@ -16,7 +16,6 @@ int use1(void)
 /*
  * check-name: eval/addressable-complex
  * check-command: test-linearize -Wno-decl -fdump-ir $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: 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