Community
Participate
Working Groups
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.
I'm not able to reproduce this problem using CDT 9.7. Re-open if you still have this problem using an updated version.