[C++ PATCH]: Fix bugs 508, 510, 512
Nathan Sidwell
nathan@codesourcery.com
Wed Oct 4 02:10:00 GMT 2000
Jason,
> Please fix the code duplication from this patch; there's no good
> reason for it.
This patch ok?
booted & tested on i686-pc-linux-gnu
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-10-04 Nathan Sidwell <nathan@codesourcery.com>
* spew.c (frob_id): New static function.
(frob_opname): Use it.
(yylex): Use it.
Index: cp/spew.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/spew.c,v
retrieving revision 1.31
diff -c -3 -p -r1.31 spew.c
*** spew.c 2000/09/11 14:19:53 1.31
--- spew.c 2000/10/04 07:52:35
*************** static SPEW_INLINE void feed_input PARAM
*** 120,125 ****
--- 120,126 ----
static SPEW_INLINE void end_input PARAMS ((void));
static SPEW_INLINE void snarf_block PARAMS ((const char *, int));
static tree snarf_defarg PARAMS ((void));
+ static int frob_id PARAMS ((int, int, tree *));
/* The list of inline functions being held off until we reach the end of
the current class declaration. */
*************** yylex ()
*** 776,823 ****
break;
case IDENTIFIER:
scan_tokens (1);
! if (nth_token (1)->yychar == SCOPE)
! {
! /* Don't interfere with the setting from an 'aggr' prefix. */
! old_looking_for_typename = looking_for_typename;
! looking_for_typename = 1;
! }
! else if (nth_token (1)->yychar == '<')
! looking_for_template = 1;
!
! trrr = lookup_name (nth_token (0)->yylval.ttype, -2);
!
! if (trrr)
! {
! yychr = identifier_type (trrr);
! switch (yychr)
! {
! case TYPENAME:
! case SELFNAME:
! case NSNAME:
! case PTYPENAME:
! lastiddecl = trrr;
!
! /* If this got special lookup, remember it. In these
! cases, we know it can't be a declarator-id. */
! if (got_scope || got_object)
! nth_token (0)->yylval.ttype = trrr;
! break;
!
! case PFUNCNAME:
! case IDENTIFIER:
! lastiddecl = trrr;
! break;
!
! default:
! my_friendly_abort (101);
! }
! }
! else
! lastiddecl = NULL_TREE;
! got_scope = NULL_TREE;
! /* and fall through to... */
case IDENTIFIER_DEFN:
case TYPENAME:
case TYPENAME_DEFN:
--- 777,790 ----
break;
case IDENTIFIER:
+ {
+ int peek;
+
scan_tokens (1);
! peek = nth_token (1)->yychar;
! yychr = frob_id (yychr, peek, &nth_token (0)->yylval.ttype);
! break;
! }
case IDENTIFIER_DEFN:
case TYPENAME:
case TYPENAME_DEFN:
*************** yyungetc (ch, rescan)
*** 938,964 ****
}
}
! /* ID is an operator name. Duplicate the hackery in yylex to determine what
! it really is. */
! tree frob_opname (id)
! tree id;
{
tree trrr;
! if (yychar == '<')
looking_for_template = 1;
! trrr = lookup_name (id, -2);
if (trrr)
{
! switch (identifier_type (trrr))
{
case TYPENAME:
case SELFNAME:
case NSNAME:
case PTYPENAME:
if (got_scope || got_object)
! id = trrr;
case PFUNCNAME:
case IDENTIFIER:
lastiddecl = trrr;
--- 905,944 ----
}
}
! /* Lexer hackery to determine what *IDP really is. */
! static int
! frob_id (yyc, peek, idp)
! int yyc;
! int peek;
! tree *idp;
{
tree trrr;
+ int old_looking_for_typename = 0;
! if (peek == SCOPE)
! {
! /* Don't interfere with the setting from an 'aggr' prefix. */
! old_looking_for_typename = looking_for_typename;
! looking_for_typename = 1;
! }
! else if (peek == '<')
looking_for_template = 1;
! trrr = lookup_name (*idp, -2);
if (trrr)
{
! yyc = identifier_type (trrr);
! switch(yyc)
{
case TYPENAME:
case SELFNAME:
case NSNAME:
case PTYPENAME:
+ /* If this got special lookup, remember it. In these
+ cases, we know it can't be a declarator-id. */
if (got_scope || got_object)
! *idp = trrr;
! /* FALLTHROUGH */
case PFUNCNAME:
case IDENTIFIER:
lastiddecl = trrr;
*************** tree frob_opname (id)
*** 970,977 ****
else
lastiddecl = NULL_TREE;
got_scope = NULL_TREE;
! got_object = NULL_TREE;
looking_for_template = 0;
return id;
}
--- 950,968 ----
else
lastiddecl = NULL_TREE;
got_scope = NULL_TREE;
! looking_for_typename = old_looking_for_typename;
looking_for_template = 0;
+ return yyc;
+ }
+
+ /* ID is an operator name. Duplicate the hackery in yylex to determine what
+ it really is. */
+
+ tree frob_opname (id)
+ tree id;
+ {
+ frob_id (0, yychar, &id);
+ got_object = NULL_TREE;
return id;
}
More information about the Gcc-patches
mailing list