Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356272 - field in anonymous union inside structure is not renamed.
Summary: field in anonymous union inside structure is not renamed.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 7.0.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 8.0.2   Edit
Assignee: Markus Schorn CLA
QA Contact: Emanuel Graf CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-31 01:54 EDT by Konstantin Stupnik CLA
Modified: 2011-09-19 08:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Stupnik CLA 2011-08-31 01:54:25 EDT
Build Identifier: 20110615-0604

if there is structure like this:

struct test_struct{
  int a;
  union{
    int u1;
    int u2;
  };
};
in the header file, and function like this:

void test()
{
  test_struct t;
  t.u1=1;
}
in .cpp file, then renaming of field u1 in headers doesn't rename it in .cpp file, and renaming it in .cpp file doesn't rename it in header.

If both structure definition and function are in the same file, both are renamed.


Reproducible: Always

Steps to Reproduce:
1. put structure shown above in header
2. put function shown above in .cpp file that includes mentioned header.
3. try to use Refactor->Rename u1 in either header or .cpp file.
Comment 1 Markus Schorn CLA 2011-09-07 04:42:03 EDT
Added fix.
Comment 2 CDT Genie CLA 2011-09-07 05:23:01 EDT
*** cdt git genie on behalf of Markus Schorn ***

    Bug 356272: Renaming fields of anonymous structs.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ec625862b2d31651e2144698615572724dad180e
Comment 3 Konstantin Stupnik CLA 2011-09-07 05:50:47 EDT
Thanks a lot Markus.
While you are on it.
In the same situation if field is used inside of macro, attempt to rename it makes nothing.
structure and macro must be in header, field reference on which rename attempt is invoked is in .cpp file.
Errors log contains error like this:
org.eclipse.jface.text.BadLocationException: First position: 'u1' at 1106, this position: 'MACRO(t)' at 1092

macro is:
#define MACRO(n) n.u1=1

Should I create separate bug for this?
Comment 4 Markus Schorn CLA 2011-09-07 07:04:59 EDT
(In reply to comment #3)
> Thanks a lot Markus.
> While you are on it.
> In the same situation if field is used inside of macro, attempt to rename it
> makes nothing.
> structure and macro must be in header, field reference on which rename attempt
> is invoked is in .cpp file.
> Errors log contains error like this:
> org.eclipse.jface.text.BadLocationException: First position: 'u1' at 1106, this
> position: 'MACRO(t)' at 1092
> macro is:
> #define MACRO(n) n.u1=1
> Should I create separate bug for this?

yes, please do so.
Comment 5 CDT Genie CLA 2011-09-19 08:23:14 EDT
*** cdt git genie on behalf of Markus Schorn ***

    Bug 356272: Renaming fields of anonymous structs.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ac6a9d985265a58344f003c3b32b8921d6e39fdf