This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++, libstdc++-v3 and, well, error messages
- To: gcc at gcc dot gnu dot org
- Subject: Re: C++, libstdc++-v3 and, well, error messages
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Tue, 21 Nov 2000 16:31:08 -0800 (PST)
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.