Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318874 - Extract Constant generates wrong declarations
Summary: Extract Constant generates wrong declarations
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 7.0.1   Edit
Assignee: Emanuel Graf CLA
QA Contact: Emanuel Graf CLA
URL:
Whiteboard:
Keywords:
Depends on: 318784
Blocks:
  Show dependency tree
 
Reported: 2010-07-05 07:10 EDT by Tomasz Wesolowski CLA
Modified: 2010-07-07 06:23 EDT (History)
0 users

See Also:


Attachments
test case update (3.19 KB, patch)
2010-07-05 07:19 EDT, Tomasz Wesolowski CLA
emanuel: iplog+
Details | Diff
fix for 8.0 (using DeclarationGenerator) (4.81 KB, patch)
2010-07-05 07:24 EDT, Tomasz Wesolowski CLA
emanuel: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Wesolowski CLA 2010-07-05 07:10:49 EDT
Build Identifier: 

The refactoring generates declaration in an incorrect way.

There are two separate problems, one applies to string constants and one to float constants.

Reproducible: Always

Steps to Reproduce:
1. Create new .c file, insert the code:

void foo() {
	const char* a = "foo";
	double d = 123.0;
}

2. Select the string "foo" and run Refactor -> Extract Constant
3. Select the value 123.0 and run Refactor -> Extract Constant
4. Observe the declarations

Generated:

static const float _123_0 = 123.0;
static const wchar_t _kos = "kos";

Expected:

static const double _123_0 = 123.0;
static const char* _kos = "kos";
Comment 1 Tomasz Wesolowski CLA 2010-07-05 07:19:50 EDT
Created attachment 173408 [details]
test case update
Comment 2 Tomasz Wesolowski CLA 2010-07-05 07:24:13 EDT
Created attachment 173409 [details]
fix for 8.0 (using DeclarationGenerator)

I'll probably need to also submit a patch for 7.0 without using the new API (see discussion in bug 312736).
Comment 3 Emanuel Graf CLA 2010-07-07 05:37:37 EDT
Fixed in HEAD and 7.0 > 20100707

I modified your patch for 7.0