Bug 396350 - Extract Function incorrectly extracts a statement refactoring a macro definition
Summary: Extract Function incorrectly extracts a statement refactoring a macro definition
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:46 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:20 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:46:21 EST
In the following program...
==========
typedef struct s
{
 char *n;
};
int main()
{
 char* o;
 #define P ((struct s *) o) 
 P->n = "Jack"; //extract
 return 0;
}
==========

...if you select the statement on line 9 and invoke the Extract Function refactoring, CDT produces the following code:
==========
typedef struct s
{
 char *n;
};

void extracted_function(char* o) {
	P->n = "Jack";
}

int main()
{
 char* o;
 #define P ((struct s *) o) 
	extracted_function(o);
 return 0;
}
==========

Macro P is undefined in the extracted function.