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]

Re: egcs 1.1.1 extremely slow


> However, I'm still not sure this is correct; as I recall, I changed
> ovl_member to use decls_match because different decls of the same function
> have to be unified.  For instance, a plain decl and a using decl.  Or a
> file-scope decl and a function-local 'extern' decl.

With a plain decl and a using decl, we don't get duplicate
declarations. With function-local 'extern's, we do (which I'd consider
a bug (*)). Therefore, my patch breaks g++.martin/overload1.C.

It is worthwhile special-casing such locals, which I attempt in the
patch below. Unfortunately, there seems to be no way of determining
that a decl is function-local except by looking at the permanent_flag.

Martin

(*) We currently don't detect the error in
void dummy()
{
  int func(int);
  int res = func(3);
}

void func(int){}

1999-01-25  Martin von Löwis  <loewis@informatik.hu-berlin.de>

	* tree.c (equal_functions): New function.
	(ovl_member): Call it.

Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.92
diff -u -r1.92 tree.c
--- tree.c	1999/01/21 21:16:22	1.92
+++ tree.c	1999/01/25 08:46:08
@@ -41,6 +41,7 @@
 static void propagate_binfo_offsets PROTO((tree, tree));
 static int avoid_overlap PROTO((tree, tree));
 static int lvalue_p_1 PROTO((tree, int));
+static int equal_function PROTO((tree, tree));
 
 #define CEIL(x,y) (((x) + (y) - 1) / (y))
 
@@ -1395,6 +1396,20 @@
   return ovl_cons (decl, chain);
 }
 
+/* Returns true iff functions are equivalent. Equivalent functions are
+   not identical only if one is a function-local extern function.
+   This assumes that function-locals don't have TREE_PERMANENT.  */
+
+static int
+equal_functions (fn1, fn2)
+     tree fn1;
+     tree fn2;
+{
+  if (!TREE_PERMANENT (fn1) || !TREE_PERMANENT (fn2))
+    return decls_match (fn1, fn2);
+  return fn1 == fn2;
+}
+
 /* True if fn is in ovl. */
 
 int
@@ -1405,9 +1420,9 @@
   if (ovl == NULL_TREE)
     return 0;
   if (TREE_CODE (ovl) != OVERLOAD)
-    return decls_match (ovl, fn);
+    return equal_functions (ovl, fn);
   for (; ovl; ovl = OVL_CHAIN (ovl))
-    if (decls_match (OVL_FUNCTION (ovl), fn))
+    if (equal_functions (OVL_FUNCTION (ovl), fn))
       return 1;
   return 0;
 }



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