aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-25 11:34:21 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-27 12:09:55 +0200
commitfd3f7de6113aebe927d9bfff0f485e48a6edf68e (patch)
tree65233a6f0e9fad30e37546e3554e6f8e083930c8
parent102baa11391d48e5da57519df53b7b8d7d751887 (diff)
downloadsparse-dev-fd3f7de6113aebe927d9bfff0f485e48a6edf68e.tar.gz
inline: comment about creating node of node on variadics
When inlining a variadic function the extra arguments are added in the declaration list as SYM_NODE but these arguments can already be SYM_NODEs. Sparse doesn't support everywhere such nested nodes (they must be merged) but in this case it's fine as the node will be merged when evaluated. Add a comment telling the situation is fine. Also, move the code to where the variadic arguments are handled since the fixed one will be anyway directly overwritten. Note: Sparse doesn't really support inlining of variadic functions but is fine when the arguments are not used (and such cases occur in the kernel). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--inline.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/inline.c b/inline.c
index 0097e4bf..d031c9b1 100644
--- a/inline.c
+++ b/inline.c
@@ -542,11 +542,15 @@ int inline_function(struct expression *expr, struct symbol *sym)
FOR_EACH_PTR(arg_list, arg) {
struct symbol *a = alloc_symbol(arg->pos, SYM_NODE);
- a->ctype.base_type = arg->ctype;
if (name) {
*a = *name;
set_replace(name, a);
add_symbol(&fn_symbol_list, a);
+ } else {
+ // This may create a node of a node but it will
+ // be resolved later when the corresponding
+ // STMT_DECLARATION will be evaluated.
+ a->ctype.base_type = arg->ctype;
}
a->initializer = arg;
add_symbol(&arg_decl, a);