This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: 2.95.2 -fsyntax-only internal compiler error on struct declaration via nested typedefs
- To: jthorn at galileo dot thp dot univie dot ac dot at
- Subject: Re: 2.95.2 -fsyntax-only internal compiler error on struct declaration via nested typedefs
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 1 Jan 2000 20:19:19 +0100
- CC: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <Pine.LNX.4.10.9912301839540.6758-201000@davinci.thp.univie.ac.at> <200001011331.OAA10321@davinci.thp.univie.ac.at>
> Alas, g++ -c gets exactly the same internal compiler error.
Thanks for your bug report. The problem is that you cannot use a
typedef-name in an elaborated-type-specifier (3.4.4/3); here is a
patch that detects this error.
Jason, Mark, is there no better way to check for a typedef?
Regards,
Martin
2000-01-01 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* decl2.c (handle_class_head): Complain about typedefs.
// Build don't link:
struct foo{};
struct bar
{
typedef int INT;
typedef foo FOO;
};
int main()
{
struct bar::INT i; // ERROR - typedef in elaborated type specifier
struct bar::FOO f; // ERROR - typedef in elaborated type specifier
}
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.292
diff -u -r1.292 decl2.c
--- decl2.c 1999/12/29 06:39:42 1.292
+++ decl2.c 2000/01/01 18:21:07
@@ -1,5 +1,5 @@
/* Process declarations and variables for C compiler.
- Copyright (C) 1988, 92-98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1988, 92-99, 2000 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@@ -5195,7 +5195,16 @@
tree decl;
if (TREE_CODE (id) == TYPE_DECL)
- decl = id;
+ {
+ /* 3.4.4/2: If this name lookup finds a typedefname, the
+ elaboratedtypespecifier is illformed. */
+ if (id != TYPE_NAME (TREE_TYPE (id)))
+ {
+ cp_error ("typedef `%D' in elaborated type specifier", id);
+ return error_mark_node;
+ }
+ decl = id;
+ }
else if (DECL_CLASS_TEMPLATE_P (id))
decl = DECL_TEMPLATE_RESULT (id);
else