It is a common mistake to place square brackets before the identifier. However, when this occurs, Clang merely says "expected unqualified-id" pointing at the first open square bracket. Also, since the identifier isn't properly parsed, attempting to use it will result in additional undeclared identifier errors.
test.cc:
const char[] str = "foo"; char a = str[1];
Clang:
test.cc:1:11: error: expected unqualified-id const char[] str = "foo"; ^ test.cc:2:10: error: use of undeclared identifier 'str' char a = str[1]; ^ 2 errors generated.
With patch:
test.cc:1:17: error: brackets go after the unqualified-id const char[] str = "foo"; ~~ ^ [] 1 error generated.
Currently, the parser will process the identifier then the brackets. Now, when a bracket appears instead of an identifier, the parser can process the brackets first, holding the location information. Then when it finds the identifier, it can will produce a better diagnostic to move the brackets and also include a fix-it hint. Other error messages have been updated to display in the correct spot. Since the identifier can now be attached to the Declarator, this will also remove the undeclared identifier errors, too.
It looks like this will behave strangely if the remaining declarator is not just a simple identifier:
... will form an 'array of three pointers to int' type, rather than a 'pointer to array of three ints' type. Instead, to get this sort of thing right, I suggest you consume the array bound, then call ParseDeclarator, then add the array bound chunks to the declarator and issue your diagnostic.
To get the diagnostic location right, you could store the location of the '[' as the identifier location in the Declarator object or similar.