From 0e6cd82908f5c649e15e6a63ad77a94f627449d2 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 2 Nov 2018 02:35:49 +0100 Subject: Fix removal of multiple consecutive 'if' nodes Despite 'if' nodes being flattened before 'if' removal, consecutive 'if' nodes can still show up for code like the following: ... if X endif if X endif ... _remove_ifs() failed to remove the second 'if' node, leading to a crash e.g. when turning on show-all mode in the menuconfig in a menu with such code (due to the unexpected 'if' node). Stuff like the above could potentially result from 'osource's with no matches, though I just spotted the error while looking over the code. Fix the 'if' removal logic to properly handle consecutive 'if' nodes. --- tests/Kifremoval | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 tests/Kifremoval (limited to 'tests') diff --git a/tests/Kifremoval b/tests/Kifremoval new file mode 100644 index 0000000..f94472c --- /dev/null +++ b/tests/Kifremoval @@ -0,0 +1,99 @@ +# Test some tricky cases that give consecutive 'if' nodes even after +# flattening. Simple cases are exercised a ton elsewhere. + +if X +endif +if X +endif + +config A + +if X +endif +if X +endif + +config B + +if X +endif +if X +endif +if X +endif + +config C + +if X + if X + if X + endif + if X + endif + endif + if X + if X + endif + if X + endif + endif + config D +endif +if X +endif + +menu "E" + if X + if X + endif + endif + if X + if X + endif + endif +endmenu + +menu "F" + if X + endif + if X + endif + if X + if X + endif + if X + endif + menu "G" + endmenu + endif +endmenu + +choice H + if X + if X + endif + endif + if X + if X + endif + endif +endchoice + +choice I + if X + endif + if X + endif + if X + if X + endif + if X + endif + config J + endif +endchoice + +if X +endif +if X +endif -- cgit v1.2.3