Bug 396351 - Extract Function incorrectly extracts case label in switch statements
Summary: Extract Function incorrectly extracts case label in switch statements
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:47 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:27 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:47:44 EST
In the following program...
==========
int main(){
 char c='A';
 switch( c )
  {
   case 'A': // extract 'A'
   break;
  }
 return 0;
}
==========

...if you select the label 'A' on line 5 and invoke the Extract Function refactoring, CDT produces the following code:
==========
char extracted_function() {
	return 'A';
}

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

This breaks the program and I would expect it not to be allowed.