Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313369

Summary: Length of character variable is not transferred to dummy argument when Extracting Procedure
Product: [Tools] PTP Reporter: Erik Toussaint <eh.toussaint>
Component: Photran.Refactoring EngineAssignee: Jeffrey Overbey <com-eclipse-dot-org>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: com-eclipse-dot-org
Version: 6.0   
Target Milestone: 6.0.7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
ExtarctProcedure character length bug fixed
none
Patch to correct ExtractProcedure
none
Modified patch - added unit test, copied in entire char selector g.watson: iplog+

Description Erik Toussaint CLA 2010-05-18 10:43:43 EDT
When refactoring, the Extract Procedure action omits a length specifier for character dummy arguments of the new procedure, giving them an implicit length of one.

Consider the following example code:

program refactor
    implicit none
    character(3) :: charvar
    charvar = 'abc'
    print *, charvar
end program refactor

This prints the string 'abc'.
Now select the line with the print statement and click 'Refactor > Extract Procedure...'. Complete the dialog and you'll end up with the following:

program refactor
    implicit none
    character(3) :: charvar
    charvar = 'abc'
    call printcharvar(charvar)
contains

    subroutine printcharvar(charvar)
        implicit none
        character :: charvar
        print *, charvar
    end subroutine

end program refactor

As you can see, the subroutine has a dummy character argument with length one. So it only prints the first character, instead of all three.
Comment 1 Abhi23 CLA 2010-07-13 13:31:51 EDT
Created attachment 174178 [details]
ExtarctProcedure character length bug fixed
Comment 2 Abhi23 CLA 2010-07-13 15:39:07 EDT
Created attachment 174224 [details]
Patch to correct ExtractProcedure
Comment 3 Jeffrey Overbey CLA 2010-09-21 15:00:24 EDT
Created attachment 179336 [details]
Modified patch - added unit test, copied in entire char selector
Comment 4 Jeffrey Overbey CLA 2010-09-21 15:02:17 EDT
Patch committed to HEAD for 7.0.  Still need to commit to PTP_4_0 for 6.0.4.
Comment 5 Jeffrey Overbey CLA 2011-03-17 09:24:04 EDT
This didn't make 6.0.4, but it will be in 6.0.7.

Patch committed to ptp_4_0 branch.