Hello, a user reported <https://bugzilla.redhat.com/show_bug.cgi?id=1199959> that indent does not support compound literals (see <http://www.drdobbs.com/the-new-c-compound-literals/184401404>) and that it can cause indent to print errors and misindent the code.
Input: #include <stdio.h> int main(int argc, char **argv) { typedef struct { char *capital; char *country; } t_association; t_association a = { "foo", "bar" }; t_association m; m = (t_association){"Paris", "France"}; m = (t_association){"Rome", "Italy"}; if (1) m = (t_association){"Paris", "France"}; else m = (t_association){"Rome", "Italy"}; return 0; } Output: $ indent -br < test.c #include <stdio.h> int main (int argc, char **argv) { typedef struct { char *capital; char *country; } t_association; t_association a = { "foo", "bar" }; t_association m; m = (t_association) { "Paris", "France"}; m = (t_association) { "Rome", "Italy"}; if (1) m = (t_association) { "Paris", "France"}; indent: Standard input:16: Error:Unmatched 'else' else m = (t_association) { "Rome", "Italy"}; return 0; } As you can see, the `m = (t_association){"Paris", "France"};' is recgnized as function call (or just a new statement block) and it's broken at the left brace. Then the real if-else lines are thought to be misballanced and an error is printed. I believe indent should handle the assignement the same way as the definition of `a' above. Also please note that a coumpound statement can be used as part of bigger expression or to be simply void expression. Any idea how to fix it? -- Petr
pgp7vJfPBZTeE.pgp
Description: PGP signature
_______________________________________________ bug-indent mailing list bug-indent@gnu.org https://lists.gnu.org/mailman/listinfo/bug-indent