C++, libstdc++-v3 and, well, error messages
Joe Buck
jbuck@racerx.synopsys.com
Tue Nov 21 16:31:00 GMT 2000
A while ago, Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> wrote:
| If you compile the following trivial snippet
|
| #include <vector>
| vector<int> v;
|
| with our current CVS sources, you'll get the following error:
|
| filename:2: syntax error before ';' token
It seems that the misleading message only comes about for file-scope
objects. If the user writes
int foo() {
vector<int> v;
}
she gets something like
v.cxx: In function `int foo()':
v.cxx:5: `vector' undeclared (first use this function)
v.cxx:5: (Each undeclared identifier is reported only once for each function it
appears in.)
v.cxx:5: parse error before '>' token
It should be possible to get better recovery for the first case, by adding
another rule. Of course the tricky part is making sure that nothing else
is broken.
What the grammar does is basically to reduce the vector<int> before the
identifier first to notype_template_declarator, then to
direct_notype_declarator, then to notype_declarator, then to fn.def1.
At that point, there's no match and the parser declares error, skipping
to the semicolon. It seems that we can, without conflict, add a rule
that handles this case.
More information about the Gcc
mailing list