[cfe-dev] Implementing missing-braces warning
Tanya Lattner
lattner at apple.com
Wed Jan 27 15:44:44 PST 2010
Hello,
I'm attempting to implement the missing-braces warning.
With this example:
int a[2][2] = { 0, 1, 2, 3 };
It should generate a warning because its missing braces around the first two values, and the last 2 (int a[2][2] = { { 0, 1 }, { 2, 3 } }).
gcc outputs the warning like this:
/tmp/warn-missing-braces.c:3: warning: missing braces around initializer
/tmp/warn-missing-braces.c:3: warning: (near initialization for ‘a[0]’)
So I have two questions.
When I output this warning, what should it look like? Should code modification hints be given? Is one warning output or one for each set of braces needed?
As for implementation details, in SemaInit::CheckSubElementType we assume brace elision. I assume that this is where I should output my warning, but when i do it there, I get one for each set (so 2 warnings). Any advice here?
Thanks,
Tanya
More information about the cfe-dev
mailing list