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

Bug 350816

Summary: [formatter] Fixed size array declaration formats wrong
Product: [Tools] CDT Reporter: Michiel Tijhuis <michiel.tijhuis>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, yevshif
Version: 8.0   
Target Milestone: 8.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Michiel Tijhuis CLA 2011-06-30 08:34:14 EDT
Build Identifier: 20110615-0604

After formatting the following array declarations the next statement is placed wrong:

    char szFirstBuffer[BUF_LENGTH + 1];
    char szAffected[13];
    char szUnaffected[13];

Becomes after formatting:

    char szFirstBuffer[BUF_LENGTH + 1];char szAffected[13];
    char szUnaffected[13];

If a single-line comment is placed after the declaration, the formatted output becomes

    char szFirstBuffer[BUF_LENGTH + 1]; // additional char for termination
char    szAffected[13];
    char szUnaffected[13];

If the size of the array is specified as a single token (i.e. [BUF_LENGTH] or [12]) everything the formatting is OK.

I did not notice this behavior in Eclipse 3.6.2 (M20110210-1200) with CDT 7.0.2, earlier versions not tested.



Reproducible: Always

Steps to Reproduce:
1. In a C-source file, declare the following:


    char szFirstBuffer[BUF_LENGTH + 1];
    char szAffected[13];
    char szUnaffected[13];

2. Format them using the code formatter
Comment 1 Anton Leherbauer CLA 2011-08-08 04:11:06 EDT
Fixed in master and 8.0.1.
Comment 2 CDT Genie CLA 2011-08-08 04:23:01 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 350816 - [formatter] Fixed size array declaration formats wrong

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=3796041aa8daca55bcc693c3eb9d54fe70c17664
Comment 3 CDT Genie CLA 2011-08-08 04:23:03 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 350816 - [formatter] Fixed size array declaration formats wrong

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