Bug 396341 - Extract Function incorrectly extracts the structure name from an element array expression
Summary: Extract Function incorrectly extracts the structure name from an element arra...
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:27 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:18 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:27:37 EST
In the following program...

==========
typedef struct s
 {
 char *n;
 }st;
int main()
 {
 st i;
 st *p;
 p = &i;
 p->n = "Jack"; // extract p
 printf("%s", p->n);
 return 0;
 }
==========

...if you select p (on line 10) and invoke the Extract Function refactoring, CDT produces the following incorrect code:

==========
typedef struct s
 {
 char *n;
 }st;
st extracted_function(st* p) {
	return p;
 }

int main()
 {
  st i;
  st *p;
  p = &i;
extracted_function(p)->n = "Jack";
  printf("%s", p->n);
  return 0;
 }
==========
The return type of the extracted function should be st*, not st.
Comment 1 Eclipse Genie CLA 2018-03-19 11:29:34 EDT
New Gerrit change created: https://git.eclipse.org/r/119687