OSDN Git Service

2004-12-21 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Dec 2004 21:20:02 +0000 (21:20 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Dec 2004 21:20:02 +0000 (21:20 +0000)
        PR c++/18984
        * pointer-set.c (pointer_set_contains): Add back.
        * pointer-set.h (pointer_set_contains): Add back.

2004-12-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/18984
        * cp-gimplify.c (cp_genericize_r): Don't insert first but instead
        check to see if contains the pointer.  Insert the statement before
        returning.

2004-12-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/18984
        * g++.dg/eh/ctor3.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92470 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/pointer-set.c
gcc/pointer-set.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/eh/ctor3.C [new file with mode: 0644]

index b9fbcfb..52682ea 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-21  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18984
+       * pointer-set.c (pointer_set_contains): Add back.
+       * pointer-set.h (pointer_set_contains): Add back.
+
 2004-12-21  Richard Henderson  <rth@redhat.com>
 
        * gimplify.c (eval_save_expr): New.
index b0c25a7..b216480 100644 (file)
@@ -1,3 +1,10 @@
+2004-12-21  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18984
+       * cp-gimplify.c (cp_genericize_r): Don't insert first but instead
+       check to see if contains the pointer.  Insert the statement before
+       returning.
+
 2004-12-21  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/14075
index 4f38739..d953156 100644 (file)
@@ -291,7 +291,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
     }
 
   /* Other than invisiref parms, don't walk the same tree twice.  */
-  if (pointer_set_insert (p_set, stmt))
+  if (pointer_set_contains (p_set, stmt))
     {
       *walk_subtrees = 0;
       return NULL_TREE;
@@ -315,14 +315,13 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
      to lower this construct before scanning it, so we need to lower these
      before doing anything else.  */
   else if (TREE_CODE (stmt) == CLEANUP_STMT)
-    {
-      *stmt_p = build2 (CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR
-                                              : TRY_FINALLY_EXPR,
-                       void_type_node,
-                       CLEANUP_BODY (stmt),
-                       CLEANUP_EXPR (stmt));
-      pointer_set_insert (p_set, *stmt_p);
-    }
+    *stmt_p = build2 (CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR
+                                            : TRY_FINALLY_EXPR,
+                     void_type_node,
+                     CLEANUP_BODY (stmt),
+                     CLEANUP_EXPR (stmt));
+
+  pointer_set_insert (p_set, *stmt_p);
   
   return NULL;
 }
index 3f79cc2..266cccf 100644 (file)
@@ -90,6 +90,29 @@ void pointer_set_destroy (struct pointer_set_t *pset)
   XDELETE (pset);
 }
 
+/* Returns nonzero if PSET contains P.  P must be nonnull.
+
+   Collisions are resolved by linear probing.  */
+int
+pointer_set_contains (struct pointer_set_t *pset, void *p)
+{
+  size_t n = hash1 (p, pset->n_slots, pset->log_slots);
+
+  while (true)
+    {
+      if (pset->slots[n] == p)
+       return 1;
+      else if (pset->slots[n] == 0)
+       return 0;
+      else
+       {
+         ++n;
+         if (n == pset->n_slots)
+           n = 0;
+       }
+    }
+}
+
 /* Subroutine of pointer_set_insert.  Inserts P into an empty
    element of SLOTS, an array of length N_SLOTS.  Returns nonzero
    if P was already present in N_SLOTS.  */
index 3c2be39..65ac9ee 100644 (file)
@@ -26,6 +26,7 @@ struct pointer_set_t;
 struct pointer_set_t *pointer_set_create (void);
 void pointer_set_destroy (struct pointer_set_t *pset);
 
+int pointer_set_contains (struct pointer_set_t *pset, void *p);
 int pointer_set_insert (struct pointer_set_t *pset, void *p);
 
 #endif  /* POINTER_SET_H  */
index 046c528..7d62fc4 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-21  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR C++/18984
+       * g++.dg/eh/ctor3.C: New test.
+
 2004-12-21  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * objc.dg/stabs-1.m: Allow section name to be quoted and
diff --git a/gcc/testsuite/g++.dg/eh/ctor3.C b/gcc/testsuite/g++.dg/eh/ctor3.C
new file mode 100644 (file)
index 0000000..378c07e
--- /dev/null
@@ -0,0 +1,18 @@
+// PR C++/18984
+//  We just to ICE as we did not add a
+// deference to invisible by reference 
+// variable
+
+// { dg-do compile }
+
+
+struct Str
+{
+    Str(const char *chars);
+    Str& operator=(const char *chars);
+    virtual operator char*() const;
+};
+Str _localName(Str fullname)
+{
+  return (char*)fullname;
+}