This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/4707: g++ complains about a "typedef", but no typedefs are there
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-gnats at gcc dot gnu dot org, dlux at dlux dot dlux dot hu, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: Wed, 4 Dec 2002 12:12:14 +0100
- Subject: Re: c++/4707: g++ complains about a "typedef", but no typedefs are there
The problem can be demonstrated with the following (illegal) code snippet:
--------------------------snip here-----------------------------
template <class T> struct A
{
void foo() { bar(T); }
void bar();
}
typedef int INT;
--------------------------snip here-----------------------------
With mainline I get the following error message:
PR4707.cc: In member function `void A<T>::foo()':
PR4707.cc:3: error: parse error before `typedef'
PR4707.cc: At global scope:
PR4707.cc:7: error: extraneous `int' ignored
PR4707.cc:7: error: template declaration of `typedef struct A<T> INT'
There are two things correct about the error message:
* The bug is in the member function `void A<T>::foo()'.
* It is in line 3 (you cannot use the template parameter T like this).
The rest is bogus:
* The parse error happens before ")" and not before the "typedef"
which comes after the end of the whole struct. You can actually
place as many members between "foo" and the end of the struct as you
want - the parser complains about the typedef.
* The last three lines of the error message are nonsense.
Hopefully, this gets fixed with the new parser.
Regards,
Volker
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4707