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.
In this case, I think you probably shouldn't allow square brackets. That is, if someone writes:
we shouldn't activate the special case.