Bug 399207 - Extract Local Variable incorrectly extracts variables in switch statements
Summary: Extract Local Variable incorrectly extracts variables in switch statements
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-27 17:37 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farnaz Behrang CLA 2013-01-27 17:37:48 EST
In the following program...
==========
int main()
{
	int a;
	char myinput='a';
	switch (myinput)
	{
	case 'a':
	a=5; // select a
	break;
	}
	return 0;
}
==========

If you select 'a' on line 8, and invoke the Extract Local Variable refactoring, CDT produces the following incorrect code:

==========
int main()
{
	int a;
	char myinput='a';
	switch (myinput)
	{
	case 'a':
		int extracted_variable = a;
		extracted_variable = 5; // select a
	break;
	}
	return 0;
}
==========

Only statements can execute after case 'a', there should not be any declaration.