| Summary: | [formatter] C99 compound literals break formatting | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Missing name <devel> |
| Component: | cdt-core | Assignee: | Project Inbox <cdt-source-nav-inbox> |
| Status: | CLOSED WORKSFORME | QA Contact: | Markus Schorn <mschorn.eclipse> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug, marco.stornelli |
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
I'm not able to reproduce this problem using CDT 9.7. Re-open if you still have this problem using an updated version. |
Build Identifier: 20110916-0149 Formatting of compound literals looks ugly in *.c, *.cpp, *.h files. In *.c files it can even break formatting for parent if/while/do/for/switch construction. Compound literal example: (foo_t) { 0, { 'a', 'b'} }; In *.cpp and *.h files formatting is still incorrect but it at least does not ruin conditional/loop statements. Reproducible: Always Steps to Reproduce: 1. In C or C++ project in *.c file paste following code: int main() { struct foo { int a; char b[2]; }; if (1) { foo structure; structure = (struct foo) { 0, { 'a', 'b'} }; } } 2. Autoformat it (using hotkey "Format Source Code" Ctrl+Shift+F). 3. Result is: int main() { struct foo { int a; char b[2]; }; if (1) { foo structure; structure = (struct foo) { 0, { 'a', 'b'}}; } } Compound literal is broken into multiple lines by formatter. Some tabs are inserted inside the curly brackets. Indentation is broken in 'if'. Expected result: formatting '(struct foo) { 0, { 'a', 'b'} }' is just fine. Should leave it as is.