Quantcast

Missing Commas in initializer list diagnostic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Missing Commas in initializer list diagnostic

Martin J. O'Riordan via cfe-dev
Hi,

This is my first message in this list (plz be gentle).

I've been wanting to contribute to llvm/clang for quite sometime and here it is.

Subject of the matter today is errors on parsing of initializer list.

When parsing a malformed initializer list, specifically one in which 1 or more commas are missing, such as this

int a[] = {1 22222 33333, 4};


The errors we get are not exactly close to what the compilee has intended.

test.c:6:18: error: expected '}'
    int a[] = {1 22222 33333, 4};
                 ^
test.c:6:15: note: to match this '{'
    int a[] = {1 22222 33333, 4};

Now the reason why I assume the commas are missing is because it seems to be the most obvious things that happened here.

So I've went ahead and created a diagnostic which I deemed as more meaningful and more likely to match what the compilee has intended.

The behaviour is to note the areas where the expected commas would be and simply suggest inserting them.

Unfortunately the output doesn't quite line up in the email. So I'm attaching a copy if an input program and what the patched clang outputs as errors

Regards,

Zaid



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

missingCommasDiag.in (204 bytes) Download Attachment
missingCommasDiag.out (1K) Download Attachment
Loading...