This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch] fix bug 510
- To: gcc-patches at gcc dot gnu dot org, jason at redhat dot com
- Subject: [C++ patch] fix bug 510
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 08 Nov 2000 16:15:38 +0000
- Organization: Codesourcery LLC
Hi,
This patch fixes bug 510, which was broken by Jason's patch
2000-10-21 Jason Merrill <jason@redhat.com>
* parse.y (operator): Set got_object from got_scope.
Set looking_for_typename.
However, I'd not installed the exact testcase from the bug report :-(
This patch saves and restores looking_for_typename, and corrects
frob_opname to do lookahead which works (yychar isn't necessarily
right at that point). The lookahead causes a line number slipage in one
test case, but that is uninteresting. The change to do_identifier
seems to be the correct handling, now that lastiddecl is correct
for operators too.
built & tested on i686-pc-linux-gnu. ok?
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-11-08 Nathan Sidwell <nathan@codesourcery.com>
* lex.c (do_identifier): Don't lookup_name for operators.
* parse.y (operator): Save looking_for_typename.
(unoperator): Restore it.
* spew.c (frob_opname): Use nth_token for lookahead.
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.220
diff -c -3 -p -r1.220 lex.c
*** lex.c 2000/11/02 19:03:58 1.220
--- lex.c 2000/11/07 15:58:54
*************** do_identifier (token, parsing, args)
*** 1264,1270 ****
register tree id;
int lexing = (parsing == 1);
! if (! lexing || IDENTIFIER_OPNAME_P (token))
id = lookup_name (token, 0);
else
id = lastiddecl;
--- 1264,1270 ----
register tree id;
int lexing = (parsing == 1);
! if (! lexing)
id = lookup_name (token, 0);
else
id = lastiddecl;
Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.198
diff -c -3 -p -r1.198 parse.y
*** parse.y 2000/10/21 21:44:04 1.198
--- parse.y 2000/11/07 15:58:56
*************** operator:
*** 3747,3755 ****
OPERATOR
{
saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
/* We look for conversion-type-id's in both the class and current
scopes, just as for ID in 'ptr->ID::'. */
! looking_for_typename = 1; got_object = got_scope;
got_scope = NULL_TREE;
}
;
--- 3747,3757 ----
OPERATOR
{
saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
+ TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
/* We look for conversion-type-id's in both the class and current
scopes, just as for ID in 'ptr->ID::'. */
! looking_for_typename = 1;
! got_object = got_scope;
got_scope = NULL_TREE;
}
;
*************** operator:
*** 3757,3763 ****
unoperator:
{ got_scope = TREE_PURPOSE (saved_scopes);
got_object = TREE_VALUE (saved_scopes);
! saved_scopes = TREE_CHAIN (saved_scopes); }
;
operator_name:
--- 3759,3767 ----
unoperator:
{ got_scope = TREE_PURPOSE (saved_scopes);
got_object = TREE_VALUE (saved_scopes);
! looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
! saved_scopes = TREE_CHAIN (saved_scopes);
! }
;
operator_name:
Index: cp/spew.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/spew.c,v
retrieving revision 1.35
diff -c -3 -p -r1.35 spew.c
*** spew.c 2000/11/01 07:32:23 1.35
--- spew.c 2000/11/07 15:59:01
*************** frob_id (yyc, peek, idp)
*** 956,962 ****
tree frob_opname (id)
tree id;
{
! frob_id (0, yychar, &id);
got_object = NULL_TREE;
return id;
}
--- 956,963 ----
tree frob_opname (id)
tree id;
{
! scan_tokens (0);
! frob_id (0, nth_token (0)->yychar, &id);
got_object = NULL_TREE;
return id;
}
Index: testsuite/g++.old-deja/g++.brendan/err-msg8.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C,v
retrieving revision 1.2
diff -c -3 -p -r1.2 err-msg8.C
*** err-msg8.C 1998/12/16 21:25:11 1.2
--- err-msg8.C 2000/11/07 15:59:01
***************
*** 1,3 ****
// Build don't link:
// GROUPS passed error-messages
! operator int ;// ERROR - declaration of `operator int' as non-function.*
--- 1,4 ----
// Build don't link:
// GROUPS passed error-messages
! operator int ;
! // ERROR - declaration of `operator int' as non-function.*
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 7 Nov 2000 <nathan@codesourcery.com>
// Origin: bug 510 wolfgang.bangerth@iwr.uni-heidelberg.de
struct Example {
template <class U> void operator= (U);
};
template <>
void Example::operator=<double> (double);