Bug 396468 - Extract Function incorrectly extracts conditional macros
Summary: Extract Function incorrectly extracts conditional macros
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-13 02:00 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:25 EDT (History)
3 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-13 02:00:21 EST
In the following program...
==========
#define F
main()
{
 int a,b,c;
 if (c==0)            /* << extract */
  #ifdef F            /*    these */
   if(a==0) printf("a",a);      /*    five */
  #else                /*    lines */
   if(b==0)    printf("b",b);  /*       >> */
 #endif{}
 }
==========

...if you select lines 5 to 9 and invoke the Extract Function refactoring, CDT produces the following incorrect code:

==========
#define F
void extracted_function(int c, int a) {
    if (c == 0)
        /* << extract */
        if (a == 0)
            printf("a", a);
    /*    five */}

main()
{
 int a,b,c;
    extracted_function(c, a);
  #else                /*      lines */
   if(b==0)    printf("b",b);  /*       >> */
 #endif{}
 }
==========

The #else in main does not have any #if.