This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix for regression in gcc.c-torture/execute/20011114-1.c


On Dec  4, 2001, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Dec  2, 2001, Alexandre Oliva <aoliva@redhat.com> wrote:
>> * tree.c (get_callee_fndecl): Follow DECL_ABSTRACT_ORIGIN if
>> DECL_INITIAL is NULL.

> FYI, it turned out that it was not my other volatile MEM patch that
> broke C++, but this one.  C++ cdtors often have DECL_ABSTRACT_ORIGIN
> and !  DECL_INITIAL, but they have nothing to do with inline functions
> and, in fact, they point to internal decls with illegal names.  We
> must not follow such ABSTRACT_ORIGINS.

> I'm testing a patch to fix this right now.

Here's the patch.  It has passed bootstrap and allowed libstdc++-v3 to
build, and it looks reasonably obvious to me, so I'm checking it in.
Note that the only functional change is the addition of
DECL_SAVED_TREE(DECL_ABSTRACT_ORIGIN(fn)) to the test, but I've taken
the opportunity to introduce a `fn' variable, instead of abusing
`addr', and to document what's going on.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>
	* tree.c (get_callee_fndecl): Only use DECL_ABSTRACT_ORIGIN if
	it has DECL_SAVED_TREE.

Index: gcc/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.224
diff -u -p -r1.224 tree.c
--- gcc/tree.c 2001/12/04 10:34:40 1.224
+++ gcc/tree.c 2001/12/04 17:09:42
@@ -4379,12 +4379,21 @@ get_callee_fndecl (call)
   if (TREE_CODE (addr) == ADDR_EXPR
       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
     {
-      addr = TREE_OPERAND (addr, 0);
+      tree fn = TREE_OPERAND (addr, 0);
 
-      if (! DECL_INITIAL (addr) && DECL_ABSTRACT_ORIGIN (addr))
-	addr = DECL_ABSTRACT_ORIGIN (addr);
+      /* If fn is a declaration of a function in a nested scope that
+         was globally declared inline, we don't set its DECL_INITIAL.
+         However, we can't blindly follow DECL_ABSTRACT_ORIGIN because
+         the C++ front-end uses it for cdtors to refer to their
+         internal declarations, that are not real functions.
+         Fortunately those don't have trees to be saved, so we can tell by
+         checking their DECL_SAVED_TREE.  */
+      if (! DECL_INITIAL (fn)
+	  && DECL_ABSTRACT_ORIGIN (fn)
+	  && DECL_SAVED_TREE (DECL_ABSTRACT_ORIGIN (fn)))
+	fn = DECL_ABSTRACT_ORIGIN (fn);
 
-      return addr;
+      return fn;
     }
 
   /* We couldn't figure out what was being called.  */

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]