Discussion:
cc-mode identifies brace-enclosed initializer list as statement block
(too old to reply)
Jefferson Carpenter
2018-04-18 07:24:44 UTC
Permalink
I'm concerned about the indentation of the following code:

void build_pages() {
idx = &mk_hcj<text>(*new hcj, {
{},
{{
"hi"
}},
});
}

I would like the "hi" text to be indented one level - not two. IOW, I
want it to be indented like this:

void build_pages() {
idx = &mk_hcj<text>(*new hcj, {
{},
{{
"hi"
}},
});
}

Placing point on the line containing "hi" and running
(c-guess-basic-syntax), the output is:

((statement-block-intro 63) (brace-list-intro 63))

So cc-mode appears to be confusing my nested brace-init-lists with
statement blocks. I understand that if two separate brace-list-intro's
were recognized, it might still indent two levels unless they were
combined somehow, but I think a good starting point would be for the
parser to be able to understand nested list-initialization.

Jefferson

Loading...