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

Bug 334805

Summary: Auto Indentation (CTRL+i) is not correct after function header with pointer return type
Product: [Tools] CDT Reporter: Peter <peter.sandelin>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, filip.gustafsson
Version: 7.0.1   
Target Milestone: 7.0.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Peter CLA 2011-01-19 11:12:05 EST
Build Identifier: M20100909-0800

When doing auto-indent (CTRL + i) it indents the braces of the function.
But only if the function returns a pointer! 
That is has '*' in the function declaration. 
Remove '*' and it works.

Example:

const int * functionx(int xxx)
const int * functionx(int xxx)
		{//NOT OK
		}//NOT OK

const int functionx(int xxx) 
{ //OK
} //OK


I notice that Auto Formatting ( CTRL+SHIFT+'f') indents correctly.

Could be related to 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298282

Reproducible: Always

Steps to Reproduce:
1. Choose project -> "Code Style" -> "K&R [built-in]"
2. Click "Edit"
2. Name it "K&R [built-in] Modified"
3. Tab "Braces" -> "Function Declaration" -> "Next Line"
4. Press "OK"
5. Write these functions in a file test.c
------------------- START ------
const int * functionx(int xxx)
{ //try auto indent on this function. CTRL + "i"
	return &xxx;
}

const int functionx(int xxx)
{ //try auto indent on this function. CTRL + "i"
	return xxx;
}
------------------- END ------
6. Mark them and auto format using CTRL + SHIFT + 'F'.
7. Now auto indent them using CTRL + 'i'.
8. The indentation of the first functions braces are indented (wrongly)!

9. Notice: Now auto indent them AGAIN using CTRL + 'i', they move one more time.
10. Notice; Mark them and then auto format them again fixes it (CTRL + SHIFT + 'F').
Comment 1 Anton Leherbauer CLA 2011-01-20 03:26:54 EST
Strange that nobody found that before.  No regression, I can even reproduce with Galileo.
Comment 2 Anton Leherbauer CLA 2011-01-20 05:22:13 EST
Note that

const int *functionx(int xxx)

works (no space between * and function name).
Comment 3 Anton Leherbauer CLA 2011-01-20 07:05:35 EST
Fixed in HEAD and cdt_7_0.
Comment 5 Anton Leherbauer CLA 2011-03-30 05:55:57 EDT
*** Bug 317279 has been marked as a duplicate of this bug. ***