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

Bug 318874

Summary: Extract Constant generates wrong declarations
Product: [Tools] CDT Reporter: Tomasz Wesolowski <kosashi>
Component: cdt-refactoringAssignee: Emanuel Graf <emanuel>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 318784    
Bug Blocks:    
Attachments:
Description Flags
test case update
emanuel: iplog+
fix for 8.0 (using DeclarationGenerator) emanuel: iplog+

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