schema compile CHANGE move disabled nodes to global unres
So that they are removed last and can be referenced
during the whole compilation.
diff --git a/src/schema_compile.c b/src/schema_compile.c
index aa3b2af..cf4eb42 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1341,6 +1341,19 @@
return lys_compile_unres_glob(ctx, unres);
}
+ /* finally, remove all disabled nodes */
+ for (i = 0; i < unres->disabled.count; ++i) {
+ node = unres->disabled.snodes[i];
+ if (node->flags & LYS_KEY) {
+ LOG_LOCSET(node, NULL, NULL, NULL);
+ LOGVAL(ctx, LYVE_REFERENCE, "Key \"%s\" is disabled by its if-features.", node->name);
+ LOG_LOCBACK(1, 0, 0, 0);
+ return LY_EVALID;
+ }
+
+ lysc_node_free(ctx, node, 1);
+ }
+
return LY_SUCCESS;
}
@@ -1386,6 +1399,7 @@
ly_set_erase(&unres->dflts, NULL);
ly_set_erase(&unres->xpath, NULL);
ly_set_erase(&unres->leafrefs, NULL);
+ ly_set_erase(&unres->disabled, NULL);
}
/**
@@ -1397,25 +1411,11 @@
static LY_ERR
lys_compile_unres_mod(struct lysc_ctx *ctx)
{
- struct lysc_node *node;
struct lysc_augment *aug;
struct lysc_deviation *dev;
struct lys_module *orig_mod = ctx->cur_mod;
uint32_t i;
- /* remove all disabled nodes */
- for (i = 0; i < ctx->disabled.count; ++i) {
- node = ctx->disabled.snodes[i];
- if (node->flags & LYS_KEY) {
- LOG_LOCSET(node, NULL, NULL, NULL);
- LOGVAL(ctx->ctx, LYVE_REFERENCE, "Key \"%s\" is disabled by its if-features.", node->name);
- LOG_LOCBACK(1, 0, 0, 0);
- return LY_EVALID;
- }
-
- lysc_node_free(ctx->ctx, node, 1);
- }
-
/* check that all augments were applied */
for (i = 0; i < ctx->augs.count; ++i) {
aug = ctx->augs.objs[i];
@@ -1462,7 +1462,6 @@
ly_set_erase(&ctx->groupings, NULL);
ly_set_erase(&ctx->tpdf_chain, NULL);
- ly_set_erase(&ctx->disabled, NULL);
if (!error) {
/* there can be no leftover deviations or augments */
diff --git a/src/schema_compile.h b/src/schema_compile.h
index 3693f55..6fc060f 100644
--- a/src/schema_compile.h
+++ b/src/schema_compile.h
@@ -47,7 +47,6 @@
instead of the module itself */
struct ly_set groupings; /**< stack for groupings circular check */
struct ly_set tpdf_chain; /**< stack for typedefs circular check */
- struct ly_set disabled; /**< set of compiled nodes whose if-feature(s) was not satisfied (stored ::lysc_node *) */
struct ly_set augs; /**< set of compiled non-applied top-level augments (stored ::lysc_augment *) */
struct ly_set devs; /**< set of compiled non-applied deviations (stored ::lysc_deviation *) */
struct ly_set uses_augs; /**< set of compiled non-applied uses augments (stored ::lysc_augment *) */
@@ -71,6 +70,7 @@
struct ly_set xpath; /**< when/must to check */
struct ly_set leafrefs; /**< to validate leafref's targets */
struct ly_set dflts; /**< set of incomplete default values */
+ struct ly_set disabled; /**< set of compiled nodes whose if-feature(s) was not satisfied (stored ::lysc_node *) */
ly_bool full_compilation; /**< flag marking that all the currently implemented modules were compiled in this
compilation (meaning that all their disabled nodes are still present) */
ly_bool recompile; /**< flag marking that a module needs to be recompiled for this compilation to succeed */
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index 2808430..17b0696 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2410,7 +2410,7 @@
/* if-features */
LY_CHECK_GOTO(ret = lys_eval_iffeatures(ctx->ctx, pnode->iffeatures, &enabled), error);
if (!enabled && !(ctx->options & (LYS_COMPILE_NO_DISABLED | LYS_COMPILE_DISABLED | LYS_COMPILE_GROUPING))) {
- ly_set_add(&ctx->disabled, node, 1, NULL);
+ ly_set_add(&ctx->unres->disabled, node, 1, NULL);
ctx->options |= LYS_COMPILE_DISABLED;
}