1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
15 struct symbol symbol_yes = {
18 .menus = LIST_HEAD_INIT(symbol_yes.menus),
19 .flags = SYMBOL_CONST|SYMBOL_VALID,
22 struct symbol symbol_mod = {
25 .menus = LIST_HEAD_INIT(symbol_mod.menus),
26 .flags = SYMBOL_CONST|SYMBOL_VALID,
29 struct symbol symbol_no = {
32 .menus = LIST_HEAD_INIT(symbol_no.menus),
33 .flags = SYMBOL_CONST|SYMBOL_VALID,
36 struct symbol *modules_sym;
37 static tristate modules_val;
38 static int sym_warnings;
40 enum symbol_type sym_get_type(struct symbol *sym)
42 enum symbol_type type = sym->type;
44 if (type == S_TRISTATE) {
45 if (sym_is_choice_value(sym) && sym->visible == yes)
47 else if (modules_val == no)
53 const char *sym_type_name(enum symbol_type type)
72 struct property *sym_get_choice_prop(struct symbol *sym)
74 struct property *prop;
76 for_all_choices(sym, prop)
81 static struct property *sym_get_default_prop(struct symbol *sym)
83 struct property *prop;
85 for_all_defaults(sym, prop) {
86 prop->visible.tri = expr_calc_value(prop->visible.expr);
87 if (prop->visible.tri != no)
93 struct property *sym_get_range_prop(struct symbol *sym)
95 struct property *prop;
97 for_all_properties(sym, prop, P_RANGE) {
98 prop->visible.tri = expr_calc_value(prop->visible.expr);
99 if (prop->visible.tri != no)
105 static long long sym_get_range_val(struct symbol *sym, int base)
118 return strtoll(sym->curr.val, NULL, base);
121 static void sym_validate_range(struct symbol *sym)
123 struct property *prop;
124 struct symbol *range_sym;
138 prop = sym_get_range_prop(sym);
141 val = strtoll(sym->curr.val, NULL, base);
142 range_sym = prop->expr->left.sym;
143 val2 = sym_get_range_val(range_sym, base);
145 range_sym = prop->expr->right.sym;
146 val2 = sym_get_range_val(range_sym, base);
150 sym->curr.val = range_sym->curr.val;
153 static void sym_set_changed(struct symbol *sym)
155 struct property *prop;
157 sym->flags |= SYMBOL_CHANGED;
158 for (prop = sym->prop; prop; prop = prop->next) {
160 prop->menu->flags |= MENU_CHANGED;
164 static void sym_set_all_changed(void)
169 sym_set_changed(sym);
172 static void sym_calc_visibility(struct symbol *sym)
174 struct property *prop;
175 struct symbol *choice_sym = NULL;
178 /* any prompt visible? */
181 if (sym_is_choice_value(sym))
182 choice_sym = prop_get_symbol(sym_get_choice_prop(sym));
184 for_all_prompts(sym, prop) {
185 prop->visible.tri = expr_calc_value(prop->visible.expr);
187 * Tristate choice_values with visibility 'mod' are
188 * not visible if the corresponding choice's value is
191 if (choice_sym && sym->type == S_TRISTATE &&
192 prop->visible.tri == mod && choice_sym->curr.tri == yes)
193 prop->visible.tri = no;
195 tri = EXPR_OR(tri, prop->visible.tri);
197 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
199 if (sym->visible != tri) {
201 sym_set_changed(sym);
203 if (sym_is_choice_value(sym))
205 /* defaulting to "yes" if no explicit "depends on" are given */
207 if (sym->dir_dep.expr)
208 tri = expr_calc_value(sym->dir_dep.expr);
209 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
211 if (sym->dir_dep.tri != tri) {
212 sym->dir_dep.tri = tri;
213 sym_set_changed(sym);
216 if (sym->rev_dep.expr)
217 tri = expr_calc_value(sym->rev_dep.expr);
218 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
220 if (sym->rev_dep.tri != tri) {
221 sym->rev_dep.tri = tri;
222 sym_set_changed(sym);
225 if (sym->implied.expr)
226 tri = expr_calc_value(sym->implied.expr);
227 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
229 if (sym->implied.tri != tri) {
230 sym->implied.tri = tri;
231 sym_set_changed(sym);
236 * Find the default symbol for a choice.
237 * First try the default values for the choice symbol
238 * Next locate the first visible choice value
239 * Return NULL if none was found
241 struct symbol *sym_choice_default(struct symbol *sym)
243 struct symbol *def_sym;
244 struct property *prop;
247 /* any of the defaults visible? */
248 for_all_defaults(sym, prop) {
249 prop->visible.tri = expr_calc_value(prop->visible.expr);
250 if (prop->visible.tri == no)
252 def_sym = prop_get_symbol(prop);
253 if (def_sym->visible != no)
257 /* just get the first visible value */
258 prop = sym_get_choice_prop(sym);
259 expr_list_for_each_sym(prop->expr, e, def_sym)
260 if (def_sym->visible != no)
263 /* failed to locate any defaults */
267 static struct symbol *sym_calc_choice(struct symbol *sym)
269 struct symbol *def_sym;
270 struct property *prop;
274 /* first calculate all choice values' visibilities */
276 prop = sym_get_choice_prop(sym);
277 expr_list_for_each_sym(prop->expr, e, def_sym) {
278 sym_calc_visibility(def_sym);
279 if (def_sym->visible != no)
280 flags &= def_sym->flags;
283 sym->flags &= flags | ~SYMBOL_DEF_USER;
285 /* is the user choice visible? */
286 def_sym = sym->def[S_DEF_USER].val;
287 if (def_sym && def_sym->visible != no)
290 def_sym = sym_choice_default(sym);
293 /* no choice? reset tristate value */
299 static void sym_warn_unmet_dep(struct symbol *sym)
301 struct gstr gs = str_new();
304 "\nWARNING: unmet direct dependencies detected for %s\n",
307 " Depends on [%c]: ",
308 sym->dir_dep.tri == mod ? 'm' : 'n');
309 expr_gstr_print(sym->dir_dep.expr, &gs);
310 str_printf(&gs, "\n");
312 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
313 " Selected by [y]:\n");
314 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
315 " Selected by [m]:\n");
317 fputs(str_get(&gs), stderr);
321 bool sym_dep_errors(void)
324 return getenv("KCONFIG_WERROR");
328 void sym_calc_value(struct symbol *sym)
330 struct symbol_value newval, oldval;
331 struct property *prop;
337 if (sym->flags & SYMBOL_VALID)
340 if (sym_is_choice_value(sym) &&
341 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
342 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
343 prop = sym_get_choice_prop(sym);
344 sym_calc_value(prop_get_symbol(prop));
347 sym->flags |= SYMBOL_VALID;
368 sym->curr.val = sym->name;
372 sym->flags &= ~SYMBOL_WRITE;
374 sym_calc_visibility(sym);
376 if (sym->visible != no)
377 sym->flags |= SYMBOL_WRITE;
379 /* set default if recursively called */
382 switch (sym_get_type(sym)) {
385 if (sym_is_choice_value(sym) && sym->visible == yes) {
386 prop = sym_get_choice_prop(sym);
387 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
389 if (sym->visible != no) {
390 /* if the symbol is visible use the user value
391 * if available, otherwise try the default value
393 if (sym_has_value(sym)) {
394 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
399 if (sym->rev_dep.tri != no)
400 sym->flags |= SYMBOL_WRITE;
401 if (!sym_is_choice(sym)) {
402 prop = sym_get_default_prop(sym);
404 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
406 if (newval.tri != no)
407 sym->flags |= SYMBOL_WRITE;
409 if (sym->implied.tri != no) {
410 sym->flags |= SYMBOL_WRITE;
411 newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
412 newval.tri = EXPR_AND(newval.tri,
417 if (sym->dir_dep.tri < sym->rev_dep.tri)
418 sym_warn_unmet_dep(sym);
419 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
421 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
427 if (sym->visible != no && sym_has_value(sym)) {
428 newval.val = sym->def[S_DEF_USER].val;
431 prop = sym_get_default_prop(sym);
433 struct symbol *ds = prop_get_symbol(prop);
435 sym->flags |= SYMBOL_WRITE;
437 newval.val = ds->curr.val;
446 if (sym_is_choice(sym) && newval.tri == yes)
447 sym->curr.val = sym_calc_choice(sym);
448 sym_validate_range(sym);
450 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
451 sym_set_changed(sym);
452 if (modules_sym == sym) {
453 sym_set_all_changed();
454 modules_val = modules_sym->curr.tri;
458 if (sym_is_choice(sym)) {
459 struct symbol *choice_sym;
461 prop = sym_get_choice_prop(sym);
462 expr_list_for_each_sym(prop->expr, e, choice_sym) {
463 if ((sym->flags & SYMBOL_WRITE) &&
464 choice_sym->visible != no)
465 choice_sym->flags |= SYMBOL_WRITE;
466 if (sym->flags & SYMBOL_CHANGED)
467 sym_set_changed(choice_sym);
471 if (sym->flags & SYMBOL_NO_WRITE)
472 sym->flags &= ~SYMBOL_WRITE;
474 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
475 set_all_choice_values(sym);
478 void sym_clear_all_valid(void)
483 sym->flags &= ~SYMBOL_VALID;
484 conf_set_changed(true);
485 sym_calc_value(modules_sym);
488 bool sym_tristate_within_range(struct symbol *sym, tristate val)
490 int type = sym_get_type(sym);
492 if (sym->visible == no)
495 if (type != S_BOOLEAN && type != S_TRISTATE)
498 if (type == S_BOOLEAN && val == mod)
500 if (sym->visible <= sym->rev_dep.tri)
502 if (sym_is_choice_value(sym) && sym->visible == yes)
504 return val >= sym->rev_dep.tri && val <= sym->visible;
507 bool sym_set_tristate_value(struct symbol *sym, tristate val)
509 tristate oldval = sym_get_tristate_value(sym);
511 if (oldval != val && !sym_tristate_within_range(sym, val))
514 if (!(sym->flags & SYMBOL_DEF_USER)) {
515 sym->flags |= SYMBOL_DEF_USER;
516 sym_set_changed(sym);
519 * setting a choice value also resets the new flag of the choice
520 * symbol and all other choice values.
522 if (sym_is_choice_value(sym) && val == yes) {
523 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
524 struct property *prop;
527 cs->def[S_DEF_USER].val = sym;
528 cs->flags |= SYMBOL_DEF_USER;
529 prop = sym_get_choice_prop(cs);
530 for (e = prop->expr; e; e = e->left.expr) {
531 if (e->right.sym->visible != no)
532 e->right.sym->flags |= SYMBOL_DEF_USER;
536 sym->def[S_DEF_USER].tri = val;
538 sym_clear_all_valid();
543 tristate sym_toggle_tristate_value(struct symbol *sym)
545 tristate oldval, newval;
547 oldval = newval = sym_get_tristate_value(sym);
560 if (sym_set_tristate_value(sym, newval))
562 } while (oldval != newval);
566 bool sym_string_valid(struct symbol *sym, const char *str)
579 if (ch == '0' && *str != 0)
581 while ((ch = *str++)) {
587 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
593 } while ((ch = *str++));
609 bool sym_string_within_range(struct symbol *sym, const char *str)
611 struct property *prop;
616 return sym_string_valid(sym, str);
618 if (!sym_string_valid(sym, str))
620 prop = sym_get_range_prop(sym);
623 val = strtoll(str, NULL, 10);
624 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
625 val <= sym_get_range_val(prop->expr->right.sym, 10);
627 if (!sym_string_valid(sym, str))
629 prop = sym_get_range_prop(sym);
632 val = strtoll(str, NULL, 16);
633 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
634 val <= sym_get_range_val(prop->expr->right.sym, 16);
639 return sym_tristate_within_range(sym, yes);
641 return sym_tristate_within_range(sym, mod);
643 return sym_tristate_within_range(sym, no);
651 bool sym_set_string_value(struct symbol *sym, const char *newval)
662 return sym_set_tristate_value(sym, yes);
664 return sym_set_tristate_value(sym, mod);
666 return sym_set_tristate_value(sym, no);
673 if (!sym_string_within_range(sym, newval))
676 if (!(sym->flags & SYMBOL_DEF_USER)) {
677 sym->flags |= SYMBOL_DEF_USER;
678 sym_set_changed(sym);
681 oldval = sym->def[S_DEF_USER].val;
682 size = strlen(newval) + 1;
683 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
685 sym->def[S_DEF_USER].val = val = xmalloc(size);
688 } else if (!oldval || strcmp(oldval, newval))
689 sym->def[S_DEF_USER].val = val = xmalloc(size);
694 free((void *)oldval);
695 sym_clear_all_valid();
701 * Find the default value associated to a symbol.
702 * For tristate symbol handle the modules=n case
703 * in which case "m" becomes "y".
704 * If the symbol does not have any default then fallback
705 * to the fixed default values.
707 const char *sym_get_string_default(struct symbol *sym)
709 struct property *prop;
711 const char *str = "";
714 sym_calc_visibility(sym);
715 sym_calc_value(modules_sym);
716 val = symbol_no.curr.tri;
718 /* If symbol has a default value look it up */
719 prop = sym_get_default_prop(sym);
724 /* The visibility may limit the value from yes => mod */
725 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
729 * The following fails to handle the situation
730 * where a default value is further limited by
733 ds = prop_get_symbol(prop);
736 str = (const char *)ds->curr.val;
741 /* Handle select statements */
742 val = EXPR_OR(val, sym->rev_dep.tri);
744 /* transpose mod to yes if modules are not enabled */
746 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
749 /* transpose mod to yes if type is bool */
750 if (sym->type == S_BOOLEAN && val == mod)
753 /* adjust the default value if this symbol is implied by another */
754 if (val < sym->implied.tri)
755 val = sym->implied.tri;
762 case mod: return "m";
763 case yes: return "y";
779 const char *sym_get_string_value(struct symbol *sym)
786 val = sym_get_tristate_value(sym);
791 sym_calc_value(modules_sym);
792 return (modules_sym->curr.tri == no) ? "n" : "m";
800 return (const char *)sym->curr.val;
803 bool sym_is_changeable(struct symbol *sym)
805 return sym->visible > sym->rev_dep.tri;
808 HASHTABLE_DEFINE(sym_hashtable, SYMBOL_HASHSIZE);
810 struct symbol *sym_lookup(const char *name, int flags)
812 struct symbol *symbol;
817 if (name[0] && !name[1]) {
819 case 'y': return &symbol_yes;
820 case 'm': return &symbol_mod;
821 case 'n': return &symbol_no;
824 hash = strhash(name);
826 hash_for_each_possible(sym_hashtable, symbol, node, hash) {
828 !strcmp(symbol->name, name) &&
829 (flags ? symbol->flags & flags
830 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
833 new_name = xstrdup(name);
839 symbol = xmalloc(sizeof(*symbol));
840 memset(symbol, 0, sizeof(*symbol));
841 symbol->name = new_name;
842 symbol->type = S_UNKNOWN;
843 symbol->flags = flags;
844 INIT_LIST_HEAD(&symbol->menus);
846 hash_add(sym_hashtable, &symbol->node, hash);
851 struct symbol *sym_find(const char *name)
853 struct symbol *symbol = NULL;
859 if (name[0] && !name[1]) {
861 case 'y': return &symbol_yes;
862 case 'm': return &symbol_mod;
863 case 'n': return &symbol_no;
866 hash = strhash(name);
868 hash_for_each_possible(sym_hashtable, symbol, node, hash) {
870 !strcmp(symbol->name, name) &&
871 !(symbol->flags & SYMBOL_CONST))
883 /* Compare matched symbols as thus:
884 * - first, symbols that match exactly
885 * - then, alphabetical sort
887 static int sym_rel_comp(const void *sym1, const void *sym2)
889 const struct sym_match *s1 = sym1;
890 const struct sym_match *s2 = sym2;
894 * - if matched length on symbol s1 is the length of that symbol,
895 * then this symbol should come first;
896 * - if matched length on symbol s2 is the length of that symbol,
897 * then this symbol should come first.
898 * Note: since the search can be a regexp, both symbols may match
899 * exactly; if this is the case, we can't decide which comes first,
900 * and we fallback to sorting alphabetically.
902 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
903 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
904 if (exact1 && !exact2)
906 if (!exact1 && exact2)
909 /* As a fallback, sort symbols alphabetically */
910 return strcmp(s1->sym->name, s2->sym->name);
913 struct symbol **sym_re_search(const char *pattern)
915 struct symbol *sym, **sym_arr = NULL;
916 struct sym_match *sym_match_arr = NULL;
923 if (strlen(pattern) == 0)
925 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
928 for_all_symbols(sym) {
929 if (sym->flags & SYMBOL_CONST || !sym->name)
931 if (regexec(&re, sym->name, 1, match, 0))
936 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
938 goto sym_re_search_free;
942 /* As regexec returned 0, we know we have a match, so
943 * we can use match[0].rm_[se]o without further checks
945 sym_match_arr[cnt].so = match[0].rm_so;
946 sym_match_arr[cnt].eo = match[0].rm_eo;
947 sym_match_arr[cnt++].sym = sym;
950 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
951 sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
953 goto sym_re_search_free;
954 for (i = 0; i < cnt; i++)
955 sym_arr[i] = sym_match_arr[i].sym;
959 /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
967 * When we check for recursive dependencies we use a stack to save
968 * current state so we can print out relevant info to user.
969 * The entries are located on the call stack so no need to free memory.
970 * Note insert() remove() must always match to properly clear the stack.
972 static struct dep_stack {
973 struct dep_stack *prev, *next;
975 struct property *prop;
979 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
981 memset(stack, 0, sizeof(*stack));
983 check_top->next = stack;
984 stack->prev = check_top;
989 static void dep_stack_remove(void)
991 check_top = check_top->prev;
993 check_top->next = NULL;
997 * Called when we have detected a recursive dependency.
998 * check_top point to the top of the stact so we use
999 * the ->prev pointer to locate the bottom of the stack.
1001 static void sym_check_print_recursive(struct symbol *last_sym)
1003 struct dep_stack *stack;
1004 struct symbol *sym, *next_sym;
1005 struct menu *menu = NULL;
1006 struct property *prop;
1007 struct dep_stack cv_stack;
1009 if (sym_is_choice_value(last_sym)) {
1010 dep_stack_insert(&cv_stack, last_sym);
1011 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
1014 for (stack = check_top; stack != NULL; stack = stack->prev)
1015 if (stack->sym == last_sym)
1018 fprintf(stderr, "unexpected recursive dependency error\n");
1022 for (; stack; stack = stack->next) {
1024 next_sym = stack->next ? stack->next->sym : last_sym;
1027 prop = stack->sym->prop;
1029 /* for choice values find the menu entry (used below) */
1030 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
1031 for (prop = sym->prop; prop; prop = prop->next) {
1037 if (stack->sym == last_sym)
1038 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1039 prop->filename, prop->lineno);
1041 if (sym_is_choice(sym)) {
1042 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1043 menu->filename, menu->lineno,
1044 sym->name ? sym->name : "<choice>",
1045 next_sym->name ? next_sym->name : "<choice>");
1046 } else if (sym_is_choice_value(sym)) {
1047 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1048 menu->filename, menu->lineno,
1049 sym->name ? sym->name : "<choice>",
1050 next_sym->name ? next_sym->name : "<choice>");
1051 } else if (stack->expr == &sym->dir_dep.expr) {
1052 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1053 prop->filename, prop->lineno,
1054 sym->name ? sym->name : "<choice>",
1055 next_sym->name ? next_sym->name : "<choice>");
1056 } else if (stack->expr == &sym->rev_dep.expr) {
1057 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1058 prop->filename, prop->lineno,
1059 sym->name ? sym->name : "<choice>",
1060 next_sym->name ? next_sym->name : "<choice>");
1061 } else if (stack->expr == &sym->implied.expr) {
1062 fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
1063 prop->filename, prop->lineno,
1064 sym->name ? sym->name : "<choice>",
1065 next_sym->name ? next_sym->name : "<choice>");
1066 } else if (stack->expr) {
1067 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1068 prop->filename, prop->lineno,
1069 sym->name ? sym->name : "<choice>",
1070 prop_get_type_name(prop->type),
1071 next_sym->name ? next_sym->name : "<choice>");
1073 fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
1074 prop->filename, prop->lineno,
1075 sym->name ? sym->name : "<choice>",
1076 prop_get_type_name(prop->type),
1077 next_sym->name ? next_sym->name : "<choice>");
1082 "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n"
1083 "subsection \"Kconfig recursive dependency limitations\"\n"
1086 if (check_top == &cv_stack)
1090 static struct symbol *sym_check_expr_deps(struct expr *e)
1099 sym = sym_check_expr_deps(e->left.expr);
1102 return sym_check_expr_deps(e->right.expr);
1104 return sym_check_expr_deps(e->left.expr);
1111 sym = sym_check_deps(e->left.sym);
1114 return sym_check_deps(e->right.sym);
1116 return sym_check_deps(e->left.sym);
1120 fprintf(stderr, "Oops! How to check %d?\n", e->type);
1124 /* return NULL when dependencies are OK */
1125 static struct symbol *sym_check_sym_deps(struct symbol *sym)
1127 struct symbol *sym2;
1128 struct property *prop;
1129 struct dep_stack stack;
1131 dep_stack_insert(&stack, sym);
1133 stack.expr = &sym->dir_dep.expr;
1134 sym2 = sym_check_expr_deps(sym->dir_dep.expr);
1138 stack.expr = &sym->rev_dep.expr;
1139 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1143 stack.expr = &sym->implied.expr;
1144 sym2 = sym_check_expr_deps(sym->implied.expr);
1150 for (prop = sym->prop; prop; prop = prop->next) {
1151 if (prop->type == P_CHOICE || prop->type == P_SELECT ||
1152 prop->type == P_IMPLY)
1155 sym2 = sym_check_expr_deps(prop->visible.expr);
1158 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1160 stack.expr = &prop->expr;
1161 sym2 = sym_check_expr_deps(prop->expr);
1173 static struct symbol *sym_check_choice_deps(struct symbol *choice)
1175 struct symbol *sym, *sym2;
1176 struct property *prop;
1178 struct dep_stack stack;
1180 dep_stack_insert(&stack, choice);
1182 prop = sym_get_choice_prop(choice);
1183 expr_list_for_each_sym(prop->expr, e, sym)
1184 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1186 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1187 sym2 = sym_check_sym_deps(choice);
1188 choice->flags &= ~SYMBOL_CHECK;
1192 expr_list_for_each_sym(prop->expr, e, sym) {
1193 sym2 = sym_check_sym_deps(sym);
1198 expr_list_for_each_sym(prop->expr, e, sym)
1199 sym->flags &= ~SYMBOL_CHECK;
1201 if (sym2 && sym_is_choice_value(sym2) &&
1202 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
1210 struct symbol *sym_check_deps(struct symbol *sym)
1212 struct symbol *sym2;
1213 struct property *prop;
1215 if (sym->flags & SYMBOL_CHECK) {
1216 sym_check_print_recursive(sym);
1219 if (sym->flags & SYMBOL_CHECKED)
1222 if (sym_is_choice_value(sym)) {
1223 struct dep_stack stack;
1225 /* for choice groups start the check with main choice symbol */
1226 dep_stack_insert(&stack, sym);
1227 prop = sym_get_choice_prop(sym);
1228 sym2 = sym_check_deps(prop_get_symbol(prop));
1230 } else if (sym_is_choice(sym)) {
1231 sym2 = sym_check_choice_deps(sym);
1233 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1234 sym2 = sym_check_sym_deps(sym);
1235 sym->flags &= ~SYMBOL_CHECK;
1241 struct symbol *prop_get_symbol(struct property *prop)
1243 if (prop->expr && (prop->expr->type == E_SYMBOL ||
1244 prop->expr->type == E_LIST))
1245 return prop->expr->left.sym;
1249 const char *prop_get_type_name(enum prop_type type)