This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch] bug 306
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ patch] bug 306
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 25 Jul 2000 20:41:15 +0100
- Organization: Codesourcery LLC
hi,
the attached fixes bug 306 where in attempting to maintain ARM
compatibility we tried to inject the nameless object a reference
was bound to into scope.
built & tested on i686-pc-linux-gnu, approved by Mark
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-07-24 Nathan Sidwell <nathan@codesourcery.com>
* decl.c (poplevel): Deal with anonymous variables at for scope.
(maybe_inject_for_scope_var): Likewise.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.658
diff -c -3 -p -r1.658 decl.c
*** decl.c 2000/07/23 19:59:41 1.658
--- decl.c 2000/07/25 14:38:10
*************** poplevel (keep, reverse, functionbody)
*** 1443,1449 ****
/* Remove declarations for all the DECLs in this level. */
for (link = decls; link; link = TREE_CHAIN (link))
{
! if (leaving_for_scope && TREE_CODE (link) == VAR_DECL)
{
tree outer_binding
= TREE_CHAIN (IDENTIFIER_BINDING (DECL_NAME (link)));
--- 1443,1450 ----
/* Remove declarations for all the DECLs in this level. */
for (link = decls; link; link = TREE_CHAIN (link))
{
! if (leaving_for_scope && TREE_CODE (link) == VAR_DECL
! && DECL_NAME (link))
{
tree outer_binding
= TREE_CHAIN (IDENTIFIER_BINDING (DECL_NAME (link)));
*************** void
*** 7897,7902 ****
--- 7898,7906 ----
maybe_inject_for_scope_var (decl)
tree decl;
{
+ if (!DECL_NAME (decl))
+ return;
+
if (current_binding_level->is_for_scope)
{
struct binding_level *outer
2000-07-25 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/for2.C: New test.
Index: testsuite/g++.old-deja/g++.other/for2.C
===================================================================
RCS file: for2.C
diff -N for2.C
*** /dev/null Tue May 5 13:32:27 1998
--- for2.C Tue Jul 25 12:22:13 2000
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+
+ // Copyright (C) 2000 Free Software Foundation, Inc.
+ // Contributed by Nathan Sidwell 24 Jul 2000 <nathan@codesourcery.com>
+
+ // Bug 306
+ // binding a reference in for scope creates nameless objects. Make sure
+ // we don't try and inject them into scope, for ARM compatibility.
+
+ void foo ()
+ {
+ for (const int &thing = 0;;)
+ ;
+ }