Details
-
Bug
-
Resolution: Out of scope
-
P4: Low
-
None
-
Qt Creator 4.3.1
-
None
Description
When using QTCreator with C the following code doesn't allow to make use of the "Complete Switch Statement" refactoring option :
typedef enum value_bug { VALUE_BUG_1, VALUE_BUG_2, VALUE_BUG_3, VALUE_BUG_4, } value_bug_t; int test_bug(int argc, char **argv) { value_bug_t value_bug = VALUE_BUG_1; // right click on the switch keyword, refactor menu only has "Rename Symbol Under Cursor" switch (value_bug) { } }
The following code allows the "Complete Switch Statement"
enum value_nobug { VALUE_NOBUG_1, VALUE_NOBUG_2, VALUE_NOBUG_3, VALUE_NOBUG_4, }; int main_no_bug(int argc, char **argv) { enum value_nobug ok = VALUE_NOBUG_1; // right click on the switch keyword, refactor menu has "Complete Switch Statement" switch (ok) { } }
Clicking on the "Complete Switch Statement" will generate the following code :
enum value_nobug { VALUE_NOBUG_1, VALUE_NOBUG_2, VALUE_NOBUG_3, VALUE_NOBUG_4, }; int main_no_bug(int argc, char **argv) { enum value_nobug ok = VALUE_NOBUG_1; switch (ok) { case VALUE_NOBUG_1: break; case VALUE_NOBUG_2: break; case VALUE_NOBUG_3: break; case VALUE_NOBUG_4: break; } }
The difference being the use of typedef to define an enumerated type in the non-working case and the use of the enum type
Debugging Entry point :