1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
14 struct symbol symbol_yes = {
17 .flags = SYMBOL_CONST|SYMBOL_VALID,
20 struct symbol symbol_mod = {
23 .flags = SYMBOL_CONST|SYMBOL_VALID,
26 struct symbol symbol_no = {
29 .flags = SYMBOL_CONST|SYMBOL_VALID,
32 struct symbol *modules_sym;
33 static tristate modules_val;
34 static int sym_warnings;
36 enum symbol_type sym_get_type(struct symbol *sym)
38 enum symbol_type type = sym->type;
40 if (type == S_TRISTATE) {
41 if (sym_is_choice_value(sym) && sym->visible == yes)
43 else if (modules_val == no)
49 const char *sym_type_name(enum symbol_type type)
68 struct property *sym_get_choice_prop(struct symbol *sym)
70 struct property *prop;
72 for_all_choices(sym, prop)
77 static struct property *sym_get_default_prop(struct symbol *sym)
79 struct property *prop;
81 for_all_defaults(sym, prop) {
82 prop->visible.tri = expr_calc_value(prop->visible.expr);
83 if (prop->visible.tri != no)
89 struct property *sym_get_range_prop(struct symbol *sym)
91 struct property *prop;
93 for_all_properties(sym, prop, P_RANGE) {
94 prop->visible.tri = expr_calc_value(prop->visible.expr);
95 if (prop->visible.tri != no)
101 static long long sym_get_range_val(struct symbol *sym, int base)
114 return strtoll(sym->curr.val, NULL, base);
117 static void sym_validate_range(struct symbol *sym)
119 struct property *prop;
120 struct symbol *range_sym;
134 prop = sym_get_range_prop(sym);
137 val = strtoll(sym->curr.val, NULL, base);
138 range_sym = prop->expr->left.sym;
139 val2 = sym_get_range_val(range_sym, base);
141 range_sym = prop->expr->right.sym;
142 val2 = sym_get_range_val(range_sym, base);
146 sym->curr.val = range_sym->curr.val;
149 static void sym_set_changed(struct symbol *sym)
151 struct property *prop;
153 sym->flags |= SYMBOL_CHANGED;
154 for (prop = sym->prop; prop; prop = prop->next) {
156 prop->menu->flags |= MENU_CHANGED;
160 static void sym_set_all_changed(void)
165 for_all_symbols(i, sym)
166 sym_set_changed(sym);
169 static void sym_calc_visibility(struct symbol *sym)
171 struct property *prop;
172 struct symbol *choice_sym = NULL;
175 /* any prompt visible? */
178 if (sym_is_choice_value(sym))
179 choice_sym = prop_get_symbol(sym_get_choice_prop(sym));
181 for_all_prompts(sym, prop) {
182 prop->visible.tri = expr_calc_value(prop->visible.expr);
184 * Tristate choice_values with visibility 'mod' are
185 * not visible if the corresponding choice's value is
188 if (choice_sym && sym->type == S_TRISTATE &&
189 prop->visible.tri == mod && choice_sym->curr.tri == yes)
190 prop->visible.tri = no;
192 tri = EXPR_OR(tri, prop->visible.tri);
194 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
196 if (sym->visible != tri) {
198 sym_set_changed(sym);
200 if (sym_is_choice_value(sym))
202 /* defaulting to "yes" if no explicit "depends on" are given */
204 if (sym->dir_dep.expr)
205 tri = expr_calc_value(sym->dir_dep.expr);
206 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
208 if (sym->dir_dep.tri != tri) {
209 sym->dir_dep.tri = tri;
210 sym_set_changed(sym);
213 if (sym->rev_dep.expr)
214 tri = expr_calc_value(sym->rev_dep.expr);
215 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
217 if (sym->rev_dep.tri != tri) {
218 sym->rev_dep.tri = tri;
219 sym_set_changed(sym);
222 if (sym->implied.expr)
223 tri = expr_calc_value(sym->implied.expr);
224 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
226 if (sym->implied.tri != tri) {
227 sym->implied.tri = tri;
228 sym_set_changed(sym);
233 * Find the default symbol for a choice.
234 * First try the default values for the choice symbol
235 * Next locate the first visible choice value
236 * Return NULL if none was found
238 struct symbol *sym_choice_default(struct symbol *sym)
240 struct symbol *def_sym;
241 struct property *prop;
244 /* any of the defaults visible? */
245 for_all_defaults(sym, prop) {
246 prop->visible.tri = expr_calc_value(prop->visible.expr);
247 if (prop->visible.tri == no)
249 def_sym = prop_get_symbol(prop);
250 if (def_sym->visible != no)
254 /* just get the first visible value */
255 prop = sym_get_choice_prop(sym);
256 expr_list_for_each_sym(prop->expr, e, def_sym)
257 if (def_sym->visible != no)
260 /* failed to locate any defaults */
264 static struct symbol *sym_calc_choice(struct symbol *sym)
266 struct symbol *def_sym;
267 struct property *prop;
271 /* first calculate all choice values' visibilities */
273 prop = sym_get_choice_prop(sym);
274 expr_list_for_each_sym(prop->expr, e, def_sym) {
275 sym_calc_visibility(def_sym);
276 if (def_sym->visible != no)
277 flags &= def_sym->flags;
280 sym->flags &= flags | ~SYMBOL_DEF_USER;
282 /* is the user choice visible? */
283 def_sym = sym->def[S_DEF_USER].val;
284 if (def_sym && def_sym->visible != no)
287 def_sym = sym_choice_default(sym);
290 /* no choice? reset tristate value */
296 static void sym_warn_unmet_dep(struct symbol *sym)
298 struct gstr gs = str_new();
301 "\nWARNING: unmet direct dependencies detected for %s\n",
304 " Depends on [%c]: ",
305 sym->dir_dep.tri == mod ? 'm' : 'n');
306 expr_gstr_print(sym->dir_dep.expr, &gs);
307 str_printf(&gs, "\n");
309 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
310 " Selected by [y]:\n");
311 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
312 " Selected by [m]:\n");
314 fputs(str_get(&gs), stderr);
318 bool sym_dep_errors(void)
321 return getenv("KCONFIG_WERROR");
325 void sym_calc_value(struct symbol *sym)
327 struct symbol_value newval, oldval;
328 struct property *prop;
334 if (sym->flags & SYMBOL_VALID)
337 if (sym_is_choice_value(sym) &&
338 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
339 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
340 prop = sym_get_choice_prop(sym);
341 sym_calc_value(prop_get_symbol(prop));
344 sym->flags |= SYMBOL_VALID;
365 sym->curr.val = sym->name;
369 sym->flags &= ~SYMBOL_WRITE;
371 sym_calc_visibility(sym);
373 if (sym->visible != no)
374 sym->flags |= SYMBOL_WRITE;
376 /* set default if recursively called */
379 switch (sym_get_type(sym)) {
382 if (sym_is_choice_value(sym) && sym->visible == yes) {
383 prop = sym_get_choice_prop(sym);
384 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
386 if (sym->visible != no) {
387 /* if the symbol is visible use the user value
388 * if available, otherwise try the default value
390 if (sym_has_value(sym)) {
391 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
396 if (sym->rev_dep.tri != no)
397 sym->flags |= SYMBOL_WRITE;
398 if (!sym_is_choice(sym)) {
399 prop = sym_get_default_prop(sym);
401 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
403 if (newval.tri != no)
404 sym->flags |= SYMBOL_WRITE;
406 if (sym->implied.tri != no) {
407 sym->flags |= SYMBOL_WRITE;
408 newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
409 newval.tri = EXPR_AND(newval.tri,
414 if (sym->dir_dep.tri < sym->rev_dep.tri)
415 sym_warn_unmet_dep(sym);
416 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
418 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
424 if (sym->visible != no && sym_has_value(sym)) {
425 newval.val = sym->def[S_DEF_USER].val;
428 prop = sym_get_default_prop(sym);
430 struct symbol *ds = prop_get_symbol(prop);
432 sym->flags |= SYMBOL_WRITE;
434 newval.val = ds->curr.val;
443 if (sym_is_choice(sym) && newval.tri == yes)
444 sym->curr.val = sym_calc_choice(sym);
445 sym_validate_range(sym);
447 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
448 sym_set_changed(sym);
449 if (modules_sym == sym) {
450 sym_set_all_changed();
451 modules_val = modules_sym->curr.tri;
455 if (sym_is_choice(sym)) {
456 struct symbol *choice_sym;
458 prop = sym_get_choice_prop(sym);
459 expr_list_for_each_sym(prop->expr, e, choice_sym) {
460 if ((sym->flags & SYMBOL_WRITE) &&
461 choice_sym->visible != no)
462 choice_sym->flags |= SYMBOL_WRITE;
463 if (sym->flags & SYMBOL_CHANGED)
464 sym_set_changed(choice_sym);
468 if (sym->flags & SYMBOL_NO_WRITE)
469 sym->flags &= ~SYMBOL_WRITE;
471 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
472 set_all_choice_values(sym);
475 void sym_clear_all_valid(void)
480 for_all_symbols(i, sym)
481 sym->flags &= ~SYMBOL_VALID;
482 conf_set_changed(true);
483 sym_calc_value(modules_sym);
486 bool sym_tristate_within_range(struct symbol *sym, tristate val)
488 int type = sym_get_type(sym);
490 if (sym->visible == no)
493 if (type != S_BOOLEAN && type != S_TRISTATE)
496 if (type == S_BOOLEAN && val == mod)
498 if (sym->visible <= sym->rev_dep.tri)
500 if (sym_is_choice_value(sym) && sym->visible == yes)
502 return val >= sym->rev_dep.tri && val <= sym->visible;
505 bool sym_set_tristate_value(struct symbol *sym, tristate val)
507 tristate oldval = sym_get_tristate_value(sym);
509 if (oldval != val && !sym_tristate_within_range(sym, val))
512 if (!(sym->flags & SYMBOL_DEF_USER)) {
513 sym->flags |= SYMBOL_DEF_USER;
514 sym_set_changed(sym);
517 * setting a choice value also resets the new flag of the choice
518 * symbol and all other choice values.
520 if (sym_is_choice_value(sym) && val == yes) {
521 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
522 struct property *prop;
525 cs->def[S_DEF_USER].val = sym;
526 cs->flags |= SYMBOL_DEF_USER;
527 prop = sym_get_choice_prop(cs);
528 for (e = prop->expr; e; e = e->left.expr) {
529 if (e->right.sym->visible != no)
530 e->right.sym->flags |= SYMBOL_DEF_USER;
534 sym->def[S_DEF_USER].tri = val;
536 sym_clear_all_valid();
541 tristate sym_toggle_tristate_value(struct symbol *sym)
543 tristate oldval, newval;
545 oldval = newval = sym_get_tristate_value(sym);
558 if (sym_set_tristate_value(sym, newval))
560 } while (oldval != newval);
564 bool sym_string_valid(struct symbol *sym, const char *str)
577 if (ch == '0' && *str != 0)
579 while ((ch = *str++)) {
585 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
591 } while ((ch = *str++));
607 bool sym_string_within_range(struct symbol *sym, const char *str)
609 struct property *prop;
614 return sym_string_valid(sym, str);
616 if (!sym_string_valid(sym, str))
618 prop = sym_get_range_prop(sym);
621 val = strtoll(str, NULL, 10);
622 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
623 val <= sym_get_range_val(prop->expr->right.sym, 10);
625 if (!sym_string_valid(sym, str))
627 prop = sym_get_range_prop(sym);
630 val = strtoll(str, NULL, 16);
631 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
632 val <= sym_get_range_val(prop->expr->right.sym, 16);
637 return sym_tristate_within_range(sym, yes);
639 return sym_tristate_within_range(sym, mod);
641 return sym_tristate_within_range(sym, no);
649 bool sym_set_string_value(struct symbol *sym, const char *newval)
660 return sym_set_tristate_value(sym, yes);
662 return sym_set_tristate_value(sym, mod);
664 return sym_set_tristate_value(sym, no);
671 if (!sym_string_within_range(sym, newval))
674 if (!(sym->flags & SYMBOL_DEF_USER)) {
675 sym->flags |= SYMBOL_DEF_USER;
676 sym_set_changed(sym);
679 oldval = sym->def[S_DEF_USER].val;
680 size = strlen(newval) + 1;
681 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
683 sym->def[S_DEF_USER].val = val = xmalloc(size);
686 } else if (!oldval || strcmp(oldval, newval))
687 sym->def[S_DEF_USER].val = val = xmalloc(size);
692 free((void *)oldval);
693 sym_clear_all_valid();
699 * Find the default value associated to a symbol.
700 * For tristate symbol handle the modules=n case
701 * in which case "m" becomes "y".
702 * If the symbol does not have any default then fallback
703 * to the fixed default values.
705 const char *sym_get_string_default(struct symbol *sym)
707 struct property *prop;
709 const char *str = "";
712 sym_calc_visibility(sym);
713 sym_calc_value(modules_sym);
714 val = symbol_no.curr.tri;
716 /* If symbol has a default value look it up */
717 prop = sym_get_default_prop(sym);
722 /* The visibility may limit the value from yes => mod */
723 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
727 * The following fails to handle the situation
728 * where a default value is further limited by
731 ds = prop_get_symbol(prop);
734 str = (const char *)ds->curr.val;
739 /* Handle select statements */
740 val = EXPR_OR(val, sym->rev_dep.tri);
742 /* transpose mod to yes if modules are not enabled */
744 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
747 /* transpose mod to yes if type is bool */
748 if (sym->type == S_BOOLEAN && val == mod)
751 /* adjust the default value if this symbol is implied by another */
752 if (val < sym->implied.tri)
753 val = sym->implied.tri;
760 case mod: return "m";
761 case yes: return "y";
777 const char *sym_get_string_value(struct symbol *sym)
784 val = sym_get_tristate_value(sym);
789 sym_calc_value(modules_sym);
790 return (modules_sym->curr.tri == no) ? "n" : "m";
798 return (const char *)sym->curr.val;
801 bool sym_is_changeable(struct symbol *sym)
803 return sym->visible > sym->rev_dep.tri;
806 static unsigned strhash(const char *s)
809 unsigned hash = 2166136261U;
811 hash = (hash ^ *s) * 0x01000193;
815 struct symbol *sym_lookup(const char *name, int flags)
817 struct symbol *symbol;
822 if (name[0] && !name[1]) {
824 case 'y': return &symbol_yes;
825 case 'm': return &symbol_mod;
826 case 'n': return &symbol_no;
829 hash = strhash(name) % SYMBOL_HASHSIZE;
831 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
833 !strcmp(symbol->name, name) &&
834 (flags ? symbol->flags & flags
835 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
838 new_name = xstrdup(name);
844 symbol = xmalloc(sizeof(*symbol));
845 memset(symbol, 0, sizeof(*symbol));
846 symbol->name = new_name;
847 symbol->type = S_UNKNOWN;
848 symbol->flags = flags;
850 symbol->next = symbol_hash[hash];
851 symbol_hash[hash] = symbol;
856 struct symbol *sym_find(const char *name)
858 struct symbol *symbol = NULL;
864 if (name[0] && !name[1]) {
866 case 'y': return &symbol_yes;
867 case 'm': return &symbol_mod;
868 case 'n': return &symbol_no;
871 hash = strhash(name) % SYMBOL_HASHSIZE;
873 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
875 !strcmp(symbol->name, name) &&
876 !(symbol->flags & SYMBOL_CONST))
888 /* Compare matched symbols as thus:
889 * - first, symbols that match exactly
890 * - then, alphabetical sort
892 static int sym_rel_comp(const void *sym1, const void *sym2)
894 const struct sym_match *s1 = sym1;
895 const struct sym_match *s2 = sym2;
899 * - if matched length on symbol s1 is the length of that symbol,
900 * then this symbol should come first;
901 * - if matched length on symbol s2 is the length of that symbol,
902 * then this symbol should come first.
903 * Note: since the search can be a regexp, both symbols may match
904 * exactly; if this is the case, we can't decide which comes first,
905 * and we fallback to sorting alphabetically.
907 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
908 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
909 if (exact1 && !exact2)
911 if (!exact1 && exact2)
914 /* As a fallback, sort symbols alphabetically */
915 return strcmp(s1->sym->name, s2->sym->name);
918 struct symbol **sym_re_search(const char *pattern)
920 struct symbol *sym, **sym_arr = NULL;
921 struct sym_match *sym_match_arr = NULL;
928 if (strlen(pattern) == 0)
930 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
933 for_all_symbols(i, sym) {
934 if (sym->flags & SYMBOL_CONST || !sym->name)
936 if (regexec(&re, sym->name, 1, match, 0))
941 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
943 goto sym_re_search_free;
947 /* As regexec returned 0, we know we have a match, so
948 * we can use match[0].rm_[se]o without further checks
950 sym_match_arr[cnt].so = match[0].rm_so;
951 sym_match_arr[cnt].eo = match[0].rm_eo;
952 sym_match_arr[cnt++].sym = sym;
955 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
956 sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
958 goto sym_re_search_free;
959 for (i = 0; i < cnt; i++)
960 sym_arr[i] = sym_match_arr[i].sym;
964 /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
972 * When we check for recursive dependencies we use a stack to save
973 * current state so we can print out relevant info to user.
974 * The entries are located on the call stack so no need to free memory.
975 * Note insert() remove() must always match to properly clear the stack.
977 static struct dep_stack {
978 struct dep_stack *prev, *next;
980 struct property *prop;
984 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
986 memset(stack, 0, sizeof(*stack));
988 check_top->next = stack;
989 stack->prev = check_top;
994 static void dep_stack_remove(void)
996 check_top = check_top->prev;
998 check_top->next = NULL;
1002 * Called when we have detected a recursive dependency.
1003 * check_top point to the top of the stact so we use
1004 * the ->prev pointer to locate the bottom of the stack.
1006 static void sym_check_print_recursive(struct symbol *last_sym)
1008 struct dep_stack *stack;
1009 struct symbol *sym, *next_sym;
1010 struct menu *menu = NULL;
1011 struct property *prop;
1012 struct dep_stack cv_stack;
1014 if (sym_is_choice_value(last_sym)) {
1015 dep_stack_insert(&cv_stack, last_sym);
1016 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
1019 for (stack = check_top; stack != NULL; stack = stack->prev)
1020 if (stack->sym == last_sym)
1023 fprintf(stderr, "unexpected recursive dependency error\n");
1027 for (; stack; stack = stack->next) {
1029 next_sym = stack->next ? stack->next->sym : last_sym;
1032 prop = stack->sym->prop;
1034 /* for choice values find the menu entry (used below) */
1035 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
1036 for (prop = sym->prop; prop; prop = prop->next) {
1042 if (stack->sym == last_sym)
1043 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1044 prop->file->name, prop->lineno);
1046 if (sym_is_choice(sym)) {
1047 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1048 menu->file->name, menu->lineno,
1049 sym->name ? sym->name : "<choice>",
1050 next_sym->name ? next_sym->name : "<choice>");
1051 } else if (sym_is_choice_value(sym)) {
1052 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1053 menu->file->name, menu->lineno,
1054 sym->name ? sym->name : "<choice>",
1055 next_sym->name ? next_sym->name : "<choice>");
1056 } else if (stack->expr == &sym->dir_dep.expr) {
1057 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1058 prop->file->name, prop->lineno,
1059 sym->name ? sym->name : "<choice>",
1060 next_sym->name ? next_sym->name : "<choice>");
1061 } else if (stack->expr == &sym->rev_dep.expr) {
1062 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1063 prop->file->name, prop->lineno,
1064 sym->name ? sym->name : "<choice>",
1065 next_sym->name ? next_sym->name : "<choice>");
1066 } else if (stack->expr == &sym->implied.expr) {
1067 fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
1068 prop->file->name, prop->lineno,
1069 sym->name ? sym->name : "<choice>",
1070 next_sym->name ? next_sym->name : "<choice>");
1071 } else if (stack->expr) {
1072 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1073 prop->file->name, prop->lineno,
1074 sym->name ? sym->name : "<choice>",
1075 prop_get_type_name(prop->type),
1076 next_sym->name ? next_sym->name : "<choice>");
1078 fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
1079 prop->file->name, prop->lineno,
1080 sym->name ? sym->name : "<choice>",
1081 prop_get_type_name(prop->type),
1082 next_sym->name ? next_sym->name : "<choice>");
1087 "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n"
1088 "subsection \"Kconfig recursive dependency limitations\"\n"
1091 if (check_top == &cv_stack)
1095 static struct symbol *sym_check_expr_deps(struct expr *e)
1104 sym = sym_check_expr_deps(e->left.expr);
1107 return sym_check_expr_deps(e->right.expr);
1109 return sym_check_expr_deps(e->left.expr);
1116 sym = sym_check_deps(e->left.sym);
1119 return sym_check_deps(e->right.sym);
1121 return sym_check_deps(e->left.sym);
1125 fprintf(stderr, "Oops! How to check %d?\n", e->type);
1129 /* return NULL when dependencies are OK */
1130 static struct symbol *sym_check_sym_deps(struct symbol *sym)
1132 struct symbol *sym2;
1133 struct property *prop;
1134 struct dep_stack stack;
1136 dep_stack_insert(&stack, sym);
1138 stack.expr = &sym->dir_dep.expr;
1139 sym2 = sym_check_expr_deps(sym->dir_dep.expr);
1143 stack.expr = &sym->rev_dep.expr;
1144 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1148 stack.expr = &sym->implied.expr;
1149 sym2 = sym_check_expr_deps(sym->implied.expr);
1155 for (prop = sym->prop; prop; prop = prop->next) {
1156 if (prop->type == P_CHOICE || prop->type == P_SELECT ||
1157 prop->type == P_IMPLY)
1160 sym2 = sym_check_expr_deps(prop->visible.expr);
1163 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1165 stack.expr = &prop->expr;
1166 sym2 = sym_check_expr_deps(prop->expr);
1178 static struct symbol *sym_check_choice_deps(struct symbol *choice)
1180 struct symbol *sym, *sym2;
1181 struct property *prop;
1183 struct dep_stack stack;
1185 dep_stack_insert(&stack, choice);
1187 prop = sym_get_choice_prop(choice);
1188 expr_list_for_each_sym(prop->expr, e, sym)
1189 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1191 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1192 sym2 = sym_check_sym_deps(choice);
1193 choice->flags &= ~SYMBOL_CHECK;
1197 expr_list_for_each_sym(prop->expr, e, sym) {
1198 sym2 = sym_check_sym_deps(sym);
1203 expr_list_for_each_sym(prop->expr, e, sym)
1204 sym->flags &= ~SYMBOL_CHECK;
1206 if (sym2 && sym_is_choice_value(sym2) &&
1207 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
1215 struct symbol *sym_check_deps(struct symbol *sym)
1217 struct symbol *sym2;
1218 struct property *prop;
1220 if (sym->flags & SYMBOL_CHECK) {
1221 sym_check_print_recursive(sym);
1224 if (sym->flags & SYMBOL_CHECKED)
1227 if (sym_is_choice_value(sym)) {
1228 struct dep_stack stack;
1230 /* for choice groups start the check with main choice symbol */
1231 dep_stack_insert(&stack, sym);
1232 prop = sym_get_choice_prop(sym);
1233 sym2 = sym_check_deps(prop_get_symbol(prop));
1235 } else if (sym_is_choice(sym)) {
1236 sym2 = sym_check_choice_deps(sym);
1238 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1239 sym2 = sym_check_sym_deps(sym);
1240 sym->flags &= ~SYMBOL_CHECK;
1246 struct symbol *prop_get_symbol(struct property *prop)
1248 if (prop->expr && (prop->expr->type == E_SYMBOL ||
1249 prop->expr->type == E_LIST))
1250 return prop->expr->left.sym;
1254 const char *prop_get_type_name(enum prop_type type)