diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-11-19 16:43:55 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-11-20 21:28:42 +0100 |
commit | 0eb8175d3e9c0d20354763d07ce3d4c0e543d988 (patch) | |
tree | 6cce0cea812e635a661a7af612b74659cd503a38 | |
parent | af0c939354599110285978dbeb2cbb65acc537be (diff) | |
download | sparse-0eb8175d3e9c0d20354763d07ce3d4c0e543d988.tar.gz |
fix expansion of function designator
The expression corresponding to the function pointer of indirect
call can be arbirarily complex. For example, it can contain a
statement expression or another call, possibly inlined.
These expressions must be expanded to insure that sub-expressions
involving 'sizeof()' or other operators taking a type as argument
(like __builtin_compatible_types_p()) are no more present (because
these expressions always evaluate to a compile-time constant and
so are not expected and thus not handled at linearization time).
However, this is not currently enforced, possibly causing some
failures during linearization with warnings like:
warning: unknown expression (4 0)
(which correspond to EXPR_TYPE).
Fix this, during the expansion of function calls, by also expanding
the corresponding designator.
References: https://lore.kernel.org/lkml/1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com/
Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Tested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r-- | expand.c | 2 | ||||
-rw-r--r-- | validation/expand/function-pointer.c | 1 |
2 files changed, 2 insertions, 1 deletions
@@ -821,6 +821,8 @@ static int expand_symbol_call(struct expression *expr, int cost) struct expression *fn = expr->fn; struct symbol *ctype = fn->ctype; + expand_expression(fn); + if (fn->type != EXPR_PREOP) return SIDE_EFFECTS; diff --git a/validation/expand/function-pointer.c b/validation/expand/function-pointer.c index 45aace16..706ef9a4 100644 --- a/validation/expand/function-pointer.c +++ b/validation/expand/function-pointer.c @@ -16,7 +16,6 @@ static void tst(struct s *s) /* * check-name: function-pointer * check-command: test-linearize -fdump-ir $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: add\\.32.*\\$1, \\$0 |