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;
35 enum symbol_type sym_get_type(struct symbol *sym)
37 enum symbol_type type = sym->type;
39 if (type == S_TRISTATE) {
40 if (sym_is_choice_value(sym) && sym->visible == yes)
42 else if (modules_val == no)
48 const char *sym_type_name(enum symbol_type type)
67 struct property *sym_get_choice_prop(struct symbol *sym)
69 struct property *prop;
71 for_all_choices(sym, prop)
76 static struct property *sym_get_default_prop(struct symbol *sym)
78 struct property *prop;
80 for_all_defaults(sym, prop) {
81 prop->visible.tri = expr_calc_value(prop->visible.expr);
82 if (prop->visible.tri != no)
88 struct property *sym_get_range_prop(struct symbol *sym)
90 struct property *prop;
92 for_all_properties(sym, prop, P_RANGE) {
93 prop->visible.tri = expr_calc_value(prop->visible.expr);
94 if (prop->visible.tri != no)
100 static long long sym_get_range_val(struct symbol *sym, int base)
113 return strtoll(sym->curr.val, NULL, base);
116 static void sym_validate_range(struct symbol *sym)
118 struct property *prop;
119 struct symbol *range_sym;
133 prop = sym_get_range_prop(sym);
136 val = strtoll(sym->curr.val, NULL, base);
137 range_sym = prop->expr->left.sym;
138 val2 = sym_get_range_val(range_sym, base);
140 range_sym = prop->expr->right.sym;
141 val2 = sym_get_range_val(range_sym, base);
145 sym->curr.val = range_sym->curr.val;
148 static void sym_set_changed(struct symbol *sym)
150 struct property *prop;
152 sym->flags |= SYMBOL_CHANGED;
153 for (prop = sym->prop; prop; prop = prop->next) {
155 prop->menu->flags |= MENU_CHANGED;
159 static void sym_set_all_changed(void)
164 for_all_symbols(i, sym)
165 sym_set_changed(sym);
168 static void sym_calc_visibility(struct symbol *sym)
170 struct property *prop;
171 struct symbol *choice_sym = NULL;
174 /* any prompt visible? */
177 if (sym_is_choice_value(sym))
178 choice_sym = prop_get_symbol(sym_get_choice_prop(sym));
180 for_all_prompts(sym, prop) {
181 prop->visible.tri = expr_calc_value(prop->visible.expr);
183 * Tristate choice_values with visibility 'mod' are
184 * not visible if the corresponding choice's value is
187 if (choice_sym && sym->type == S_TRISTATE &&
188 prop->visible.tri == mod && choice_sym->curr.tri == yes)
189 prop->visible.tri = no;
191 tri = EXPR_OR(tri, prop->visible.tri);
193 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
195 if (sym->visible != tri) {
197 sym_set_changed(sym);
199 if (sym_is_choice_value(sym))
201 /* defaulting to "yes" if no explicit "depends on" are given */
203 if (sym->dir_dep.expr)
204 tri = expr_calc_value(sym->dir_dep.expr);
205 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
207 if (sym->dir_dep.tri != tri) {
208 sym->dir_dep.tri = tri;
209 sym_set_changed(sym);
212 if (sym->rev_dep.expr)
213 tri = expr_calc_value(sym->rev_dep.expr);
214 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
216 if (sym->rev_dep.tri != tri) {
217 sym->rev_dep.tri = tri;
218 sym_set_changed(sym);
221 if (sym->implied.expr)
222 tri = expr_calc_value(sym->implied.expr);
223 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
225 if (sym->implied.tri != tri) {
226 sym->implied.tri = tri;
227 sym_set_changed(sym);
232 * Find the default symbol for a choice.
233 * First try the default values for the choice symbol
234 * Next locate the first visible choice value
235 * Return NULL if none was found
237 struct symbol *sym_choice_default(struct symbol *sym)
239 struct symbol *def_sym;
240 struct property *prop;
243 /* any of the defaults visible? */
244 for_all_defaults(sym, prop) {
245 prop->visible.tri = expr_calc_value(prop->visible.expr);
246 if (prop->visible.tri == no)
248 def_sym = prop_get_symbol(prop);
249 if (def_sym->visible != no)
253 /* just get the first visible value */
254 prop = sym_get_choice_prop(sym);
255 expr_list_for_each_sym(prop->expr, e, def_sym)
256 if (def_sym->visible != no)
259 /* failed to locate any defaults */
263 static struct symbol *sym_calc_choice(struct symbol *sym)
265 struct symbol *def_sym;
266 struct property *prop;
270 /* first calculate all choice values' visibilities */
272 prop = sym_get_choice_prop(sym);
273 expr_list_for_each_sym(prop->expr, e, def_sym) {
274 sym_calc_visibility(def_sym);
275 if (def_sym->visible != no)
276 flags &= def_sym->flags;
279 sym->flags &= flags | ~SYMBOL_DEF_USER;
281 /* is the user choice visible? */
282 def_sym = sym->def[S_DEF_USER].val;
283 if (def_sym && def_sym->visible != no)
286 def_sym = sym_choice_default(sym);
289 /* no choice? reset tristate value */
295 static void sym_warn_unmet_dep(struct symbol *sym)
297 struct gstr gs = str_new();
300 "\nWARNING: unmet direct dependencies detected for %s\n",
303 " Depends on [%c]: ",
304 sym->dir_dep.tri == mod ? 'm' : 'n');
305 expr_gstr_print(sym->dir_dep.expr, &gs);
306 str_printf(&gs, "\n");
308 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
309 " Selected by [y]:\n");
310 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
311 " Selected by [m]:\n");
313 fputs(str_get(&gs), stderr);
316 void sym_calc_value(struct symbol *sym)
318 struct symbol_value newval, oldval;
319 struct property *prop;
325 if (sym->flags & SYMBOL_VALID)
328 if (sym_is_choice_value(sym) &&
329 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
330 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
331 prop = sym_get_choice_prop(sym);
332 sym_calc_value(prop_get_symbol(prop));
335 sym->flags |= SYMBOL_VALID;
347 newval = symbol_no.curr;
350 sym->curr.val = sym->name;
354 sym->flags &= ~SYMBOL_WRITE;
356 sym_calc_visibility(sym);
358 if (sym->visible != no)
359 sym->flags |= SYMBOL_WRITE;
361 /* set default if recursively called */
364 switch (sym_get_type(sym)) {
367 if (sym_is_choice_value(sym) && sym->visible == yes) {
368 prop = sym_get_choice_prop(sym);
369 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
371 if (sym->visible != no) {
372 /* if the symbol is visible use the user value
373 * if available, otherwise try the default value
375 if (sym_has_value(sym)) {
376 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
381 if (sym->rev_dep.tri != no)
382 sym->flags |= SYMBOL_WRITE;
383 if (!sym_is_choice(sym)) {
384 prop = sym_get_default_prop(sym);
386 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
388 if (newval.tri != no)
389 sym->flags |= SYMBOL_WRITE;
391 if (sym->implied.tri != no) {
392 sym->flags |= SYMBOL_WRITE;
393 newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
394 newval.tri = EXPR_AND(newval.tri,
399 if (sym->dir_dep.tri < sym->rev_dep.tri)
400 sym_warn_unmet_dep(sym);
401 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
403 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
409 if (sym->visible != no && sym_has_value(sym)) {
410 newval.val = sym->def[S_DEF_USER].val;
413 prop = sym_get_default_prop(sym);
415 struct symbol *ds = prop_get_symbol(prop);
417 sym->flags |= SYMBOL_WRITE;
419 newval.val = ds->curr.val;
428 if (sym_is_choice(sym) && newval.tri == yes)
429 sym->curr.val = sym_calc_choice(sym);
430 sym_validate_range(sym);
432 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
433 sym_set_changed(sym);
434 if (modules_sym == sym) {
435 sym_set_all_changed();
436 modules_val = modules_sym->curr.tri;
440 if (sym_is_choice(sym)) {
441 struct symbol *choice_sym;
443 prop = sym_get_choice_prop(sym);
444 expr_list_for_each_sym(prop->expr, e, choice_sym) {
445 if ((sym->flags & SYMBOL_WRITE) &&
446 choice_sym->visible != no)
447 choice_sym->flags |= SYMBOL_WRITE;
448 if (sym->flags & SYMBOL_CHANGED)
449 sym_set_changed(choice_sym);
453 if (sym->flags & SYMBOL_NO_WRITE)
454 sym->flags &= ~SYMBOL_WRITE;
456 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
457 set_all_choice_values(sym);
460 void sym_clear_all_valid(void)
465 for_all_symbols(i, sym)
466 sym->flags &= ~SYMBOL_VALID;
467 conf_set_changed(true);
468 sym_calc_value(modules_sym);
471 bool sym_tristate_within_range(struct symbol *sym, tristate val)
473 int type = sym_get_type(sym);
475 if (sym->visible == no)
478 if (type != S_BOOLEAN && type != S_TRISTATE)
481 if (type == S_BOOLEAN && val == mod)
483 if (sym->visible <= sym->rev_dep.tri)
485 if (sym_is_choice_value(sym) && sym->visible == yes)
487 return val >= sym->rev_dep.tri && val <= sym->visible;
490 bool sym_set_tristate_value(struct symbol *sym, tristate val)
492 tristate oldval = sym_get_tristate_value(sym);
494 if (oldval != val && !sym_tristate_within_range(sym, val))
497 if (!(sym->flags & SYMBOL_DEF_USER)) {
498 sym->flags |= SYMBOL_DEF_USER;
499 sym_set_changed(sym);
502 * setting a choice value also resets the new flag of the choice
503 * symbol and all other choice values.
505 if (sym_is_choice_value(sym) && val == yes) {
506 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
507 struct property *prop;
510 cs->def[S_DEF_USER].val = sym;
511 cs->flags |= SYMBOL_DEF_USER;
512 prop = sym_get_choice_prop(cs);
513 for (e = prop->expr; e; e = e->left.expr) {
514 if (e->right.sym->visible != no)
515 e->right.sym->flags |= SYMBOL_DEF_USER;
519 sym->def[S_DEF_USER].tri = val;
521 sym_clear_all_valid();
526 tristate sym_toggle_tristate_value(struct symbol *sym)
528 tristate oldval, newval;
530 oldval = newval = sym_get_tristate_value(sym);
543 if (sym_set_tristate_value(sym, newval))
545 } while (oldval != newval);
549 bool sym_string_valid(struct symbol *sym, const char *str)
562 if (ch == '0' && *str != 0)
564 while ((ch = *str++)) {
570 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
576 } while ((ch = *str++));
592 bool sym_string_within_range(struct symbol *sym, const char *str)
594 struct property *prop;
599 return sym_string_valid(sym, str);
601 if (!sym_string_valid(sym, str))
603 prop = sym_get_range_prop(sym);
606 val = strtoll(str, NULL, 10);
607 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
608 val <= sym_get_range_val(prop->expr->right.sym, 10);
610 if (!sym_string_valid(sym, str))
612 prop = sym_get_range_prop(sym);
615 val = strtoll(str, NULL, 16);
616 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
617 val <= sym_get_range_val(prop->expr->right.sym, 16);
622 return sym_tristate_within_range(sym, yes);
624 return sym_tristate_within_range(sym, mod);
626 return sym_tristate_within_range(sym, no);
634 bool sym_set_string_value(struct symbol *sym, const char *newval)
645 return sym_set_tristate_value(sym, yes);
647 return sym_set_tristate_value(sym, mod);
649 return sym_set_tristate_value(sym, no);
656 if (!sym_string_within_range(sym, newval))
659 if (!(sym->flags & SYMBOL_DEF_USER)) {
660 sym->flags |= SYMBOL_DEF_USER;
661 sym_set_changed(sym);
664 oldval = sym->def[S_DEF_USER].val;
665 size = strlen(newval) + 1;
666 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
668 sym->def[S_DEF_USER].val = val = xmalloc(size);
671 } else if (!oldval || strcmp(oldval, newval))
672 sym->def[S_DEF_USER].val = val = xmalloc(size);
677 free((void *)oldval);
678 sym_clear_all_valid();
684 * Find the default value associated to a symbol.
685 * For tristate symbol handle the modules=n case
686 * in which case "m" becomes "y".
687 * If the symbol does not have any default then fallback
688 * to the fixed default values.
690 const char *sym_get_string_default(struct symbol *sym)
692 struct property *prop;
694 const char *str = "";
697 sym_calc_visibility(sym);
698 sym_calc_value(modules_sym);
699 val = symbol_no.curr.tri;
701 /* If symbol has a default value look it up */
702 prop = sym_get_default_prop(sym);
707 /* The visibility may limit the value from yes => mod */
708 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
712 * The following fails to handle the situation
713 * where a default value is further limited by
716 ds = prop_get_symbol(prop);
719 str = (const char *)ds->curr.val;
724 /* Handle select statements */
725 val = EXPR_OR(val, sym->rev_dep.tri);
727 /* transpose mod to yes if modules are not enabled */
729 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
732 /* transpose mod to yes if type is bool */
733 if (sym->type == S_BOOLEAN && val == mod)
736 /* adjust the default value if this symbol is implied by another */
737 if (val < sym->implied.tri)
738 val = sym->implied.tri;
745 case mod: return "m";
746 case yes: return "y";
759 const char *sym_get_string_value(struct symbol *sym)
766 val = sym_get_tristate_value(sym);
771 sym_calc_value(modules_sym);
772 return (modules_sym->curr.tri == no) ? "n" : "m";
780 return (const char *)sym->curr.val;
783 bool sym_is_changeable(struct symbol *sym)
785 return sym->visible > sym->rev_dep.tri;
788 static unsigned strhash(const char *s)
791 unsigned hash = 2166136261U;
793 hash = (hash ^ *s) * 0x01000193;
797 struct symbol *sym_lookup(const char *name, int flags)
799 struct symbol *symbol;
804 if (name[0] && !name[1]) {
806 case 'y': return &symbol_yes;
807 case 'm': return &symbol_mod;
808 case 'n': return &symbol_no;
811 hash = strhash(name) % SYMBOL_HASHSIZE;
813 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
815 !strcmp(symbol->name, name) &&
816 (flags ? symbol->flags & flags
817 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
820 new_name = xstrdup(name);
826 symbol = xmalloc(sizeof(*symbol));
827 memset(symbol, 0, sizeof(*symbol));
828 symbol->name = new_name;
829 symbol->type = S_UNKNOWN;
830 symbol->flags = flags;
832 symbol->next = symbol_hash[hash];
833 symbol_hash[hash] = symbol;
838 struct symbol *sym_find(const char *name)
840 struct symbol *symbol = NULL;
846 if (name[0] && !name[1]) {
848 case 'y': return &symbol_yes;
849 case 'm': return &symbol_mod;
850 case 'n': return &symbol_no;
853 hash = strhash(name) % SYMBOL_HASHSIZE;
855 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
857 !strcmp(symbol->name, name) &&
858 !(symbol->flags & SYMBOL_CONST))
870 /* Compare matched symbols as thus:
871 * - first, symbols that match exactly
872 * - then, alphabetical sort
874 static int sym_rel_comp(const void *sym1, const void *sym2)
876 const struct sym_match *s1 = sym1;
877 const struct sym_match *s2 = sym2;
881 * - if matched length on symbol s1 is the length of that symbol,
882 * then this symbol should come first;
883 * - if matched length on symbol s2 is the length of that symbol,
884 * then this symbol should come first.
885 * Note: since the search can be a regexp, both symbols may match
886 * exactly; if this is the case, we can't decide which comes first,
887 * and we fallback to sorting alphabetically.
889 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
890 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
891 if (exact1 && !exact2)
893 if (!exact1 && exact2)
896 /* As a fallback, sort symbols alphabetically */
897 return strcmp(s1->sym->name, s2->sym->name);
900 struct symbol **sym_re_search(const char *pattern)
902 struct symbol *sym, **sym_arr = NULL;
903 struct sym_match *sym_match_arr = NULL;
910 if (strlen(pattern) == 0)
912 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
915 for_all_symbols(i, sym) {
916 if (sym->flags & SYMBOL_CONST || !sym->name)
918 if (regexec(&re, sym->name, 1, match, 0))
923 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
925 goto sym_re_search_free;
929 /* As regexec returned 0, we know we have a match, so
930 * we can use match[0].rm_[se]o without further checks
932 sym_match_arr[cnt].so = match[0].rm_so;
933 sym_match_arr[cnt].eo = match[0].rm_eo;
934 sym_match_arr[cnt++].sym = sym;
937 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
938 sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
940 goto sym_re_search_free;
941 for (i = 0; i < cnt; i++)
942 sym_arr[i] = sym_match_arr[i].sym;
946 /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
954 * When we check for recursive dependencies we use a stack to save
955 * current state so we can print out relevant info to user.
956 * The entries are located on the call stack so no need to free memory.
957 * Note insert() remove() must always match to properly clear the stack.
959 static struct dep_stack {
960 struct dep_stack *prev, *next;
962 struct property *prop;
966 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
968 memset(stack, 0, sizeof(*stack));
970 check_top->next = stack;
971 stack->prev = check_top;
976 static void dep_stack_remove(void)
978 check_top = check_top->prev;
980 check_top->next = NULL;
984 * Called when we have detected a recursive dependency.
985 * check_top point to the top of the stact so we use
986 * the ->prev pointer to locate the bottom of the stack.
988 static void sym_check_print_recursive(struct symbol *last_sym)
990 struct dep_stack *stack;
991 struct symbol *sym, *next_sym;
992 struct menu *menu = NULL;
993 struct property *prop;
994 struct dep_stack cv_stack;
996 if (sym_is_choice_value(last_sym)) {
997 dep_stack_insert(&cv_stack, last_sym);
998 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
1001 for (stack = check_top; stack != NULL; stack = stack->prev)
1002 if (stack->sym == last_sym)
1005 fprintf(stderr, "unexpected recursive dependency error\n");
1009 for (; stack; stack = stack->next) {
1011 next_sym = stack->next ? stack->next->sym : last_sym;
1014 prop = stack->sym->prop;
1016 /* for choice values find the menu entry (used below) */
1017 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
1018 for (prop = sym->prop; prop; prop = prop->next) {
1024 if (stack->sym == last_sym)
1025 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1026 prop->file->name, prop->lineno);
1028 if (sym_is_choice(sym)) {
1029 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1030 menu->file->name, menu->lineno,
1031 sym->name ? sym->name : "<choice>",
1032 next_sym->name ? next_sym->name : "<choice>");
1033 } else if (sym_is_choice_value(sym)) {
1034 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1035 menu->file->name, menu->lineno,
1036 sym->name ? sym->name : "<choice>",
1037 next_sym->name ? next_sym->name : "<choice>");
1038 } else if (stack->expr == &sym->dir_dep.expr) {
1039 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1040 prop->file->name, prop->lineno,
1041 sym->name ? sym->name : "<choice>",
1042 next_sym->name ? next_sym->name : "<choice>");
1043 } else if (stack->expr == &sym->rev_dep.expr) {
1044 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1045 prop->file->name, prop->lineno,
1046 sym->name ? sym->name : "<choice>",
1047 next_sym->name ? next_sym->name : "<choice>");
1048 } else if (stack->expr == &sym->implied.expr) {
1049 fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
1050 prop->file->name, prop->lineno,
1051 sym->name ? sym->name : "<choice>",
1052 next_sym->name ? next_sym->name : "<choice>");
1053 } else if (stack->expr) {
1054 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1055 prop->file->name, prop->lineno,
1056 sym->name ? sym->name : "<choice>",
1057 prop_get_type_name(prop->type),
1058 next_sym->name ? next_sym->name : "<choice>");
1060 fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
1061 prop->file->name, prop->lineno,
1062 sym->name ? sym->name : "<choice>",
1063 prop_get_type_name(prop->type),
1064 next_sym->name ? next_sym->name : "<choice>");
1069 "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n"
1070 "subsection \"Kconfig recursive dependency limitations\"\n"
1073 if (check_top == &cv_stack)
1077 static struct symbol *sym_check_expr_deps(struct expr *e)
1086 sym = sym_check_expr_deps(e->left.expr);
1089 return sym_check_expr_deps(e->right.expr);
1091 return sym_check_expr_deps(e->left.expr);
1098 sym = sym_check_deps(e->left.sym);
1101 return sym_check_deps(e->right.sym);
1103 return sym_check_deps(e->left.sym);
1107 fprintf(stderr, "Oops! How to check %d?\n", e->type);
1111 /* return NULL when dependencies are OK */
1112 static struct symbol *sym_check_sym_deps(struct symbol *sym)
1114 struct symbol *sym2;
1115 struct property *prop;
1116 struct dep_stack stack;
1118 dep_stack_insert(&stack, sym);
1120 stack.expr = &sym->dir_dep.expr;
1121 sym2 = sym_check_expr_deps(sym->dir_dep.expr);
1125 stack.expr = &sym->rev_dep.expr;
1126 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1130 stack.expr = &sym->implied.expr;
1131 sym2 = sym_check_expr_deps(sym->implied.expr);
1137 for (prop = sym->prop; prop; prop = prop->next) {
1138 if (prop->type == P_CHOICE || prop->type == P_SELECT ||
1139 prop->type == P_IMPLY)
1142 sym2 = sym_check_expr_deps(prop->visible.expr);
1145 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1147 stack.expr = &prop->expr;
1148 sym2 = sym_check_expr_deps(prop->expr);
1160 static struct symbol *sym_check_choice_deps(struct symbol *choice)
1162 struct symbol *sym, *sym2;
1163 struct property *prop;
1165 struct dep_stack stack;
1167 dep_stack_insert(&stack, choice);
1169 prop = sym_get_choice_prop(choice);
1170 expr_list_for_each_sym(prop->expr, e, sym)
1171 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1173 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1174 sym2 = sym_check_sym_deps(choice);
1175 choice->flags &= ~SYMBOL_CHECK;
1179 expr_list_for_each_sym(prop->expr, e, sym) {
1180 sym2 = sym_check_sym_deps(sym);
1185 expr_list_for_each_sym(prop->expr, e, sym)
1186 sym->flags &= ~SYMBOL_CHECK;
1188 if (sym2 && sym_is_choice_value(sym2) &&
1189 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
1197 struct symbol *sym_check_deps(struct symbol *sym)
1199 struct symbol *sym2;
1200 struct property *prop;
1202 if (sym->flags & SYMBOL_CHECK) {
1203 sym_check_print_recursive(sym);
1206 if (sym->flags & SYMBOL_CHECKED)
1209 if (sym_is_choice_value(sym)) {
1210 struct dep_stack stack;
1212 /* for choice groups start the check with main choice symbol */
1213 dep_stack_insert(&stack, sym);
1214 prop = sym_get_choice_prop(sym);
1215 sym2 = sym_check_deps(prop_get_symbol(prop));
1217 } else if (sym_is_choice(sym)) {
1218 sym2 = sym_check_choice_deps(sym);
1220 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1221 sym2 = sym_check_sym_deps(sym);
1222 sym->flags &= ~SYMBOL_CHECK;
1228 struct symbol *prop_get_symbol(struct property *prop)
1230 if (prop->expr && (prop->expr->type == E_SYMBOL ||
1231 prop->expr->type == E_LIST))
1232 return prop->expr->left.sym;
1236 const char *prop_get_type_name(enum prop_type type)