Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334805 - Auto Indentation (CTRL+i) is not correct after function header with pointer return type
Summary: Auto Indentation (CTRL+i) is not correct after function header with pointer r...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 7.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 7.0.2   Edit
Assignee: Anton Leherbauer CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
: 317279 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-19 11:12 EST by Peter CLA
Modified: 2011-03-30 05:55 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***