For this erroneous C++ test case:
extern void f(char**);
int main(int argc, char** argv) { f(argv[]); }
g++ reports
foo.cc: In function int main(int, char**):
foo.cc:2: error: expected primary-expression before ] token
This is pretty good, but I question the use of the term "primary-expression".
Primary-expression is slightly technical for this error, and, more improtantly,
what is missing is not a primary-expression; it is any expression at all.
Aside from avoiding the term "primary-expression", we can do better in this
specific case. We actually know that we just saw '[' and that we are looking
for an array subscript. We could say "missing subscript". In other words,
let's take advantage of the fact that we have a recursive descent parser to put
more context into our error messages.
Finally, I'll note in passing that if I use -fshow-column I get the exact right
position, and in that case the phrase "before ']' token" is not very useful.
--
Summary: C++: "expected primary-expression" error could be more
useful
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39858