Bug 396353 - Extract Function incorrectly extracts the case statement with its label in switch statements
Summary: Extract Function incorrectly extracts the case statement with its label in sw...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.1   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: 2012-12-11 17:51 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:19 EDT (History)
4 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 2012-12-11 17:51:57 EST
In the following program...
==========
int main(){
 char c='A';
 switch( c )
  {
   case 'A': // extract
   break;
  }
 return 0;
}
==========

...if you select "case 'A':" on line 5 and invoke the Extract Function refactoring, CDT produces the following code:
==========
void extracted_function() {
	case 'A':
	// extract
}

int main() {
 char c='A';
 switch( c )
  {
	extracted_function();
   break;
  }
 return 0;
}
==========

This breaks the program and I would expect it to be disallowed.
Comment 1 Eclipse Genie CLA 2018-03-20 09:39:00 EDT
New Gerrit change created: https://git.eclipse.org/r/119785