This is the mail archive of the 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 <> wrote:

> On Dec  2, 2001, Alexandre Oliva <> wrote:
>> * tree.c (get_callee_fndecl): Follow DECL_ABSTRACT_ORIGIN if

> 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  <>
	* tree.c (get_callee_fndecl): Only use DECL_ABSTRACT_ORIGIN if

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)
-      return addr;
+      return fn;
   /* We couldn't figure out what was being called.  */

Alexandre Oliva   Enjoy Guarana', see
Red Hat GCC Developer                  aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
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]