OSDN Git Service

* g++.dg/init/new2.C: New test.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Mar 2002 19:16:36 +0000 (19:16 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Mar 2002 19:16:36 +0000 (19:16 +0000)
PR c++/4884
* call.c (build_op_delete_call): Allow for the fact the placement
may be a COMPOUND_EXPR.

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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/new2.C [new file with mode: 0644]

index a9b75a9..7bd5c22 100644 (file)
@@ -1,3 +1,9 @@
+2002-03-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/4884
+       * call.c (build_op_delete_call): Allow for the fact the placement
+       may be a COMPOUND_EXPR.
+       
 2002-03-27  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * cp-lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine.
index 9d26861..8804a61 100644 (file)
@@ -3611,15 +3611,22 @@ build_op_delete_call (code, addr, size, flags, placement)
 
   if (placement)
     {
-      /* placement is a CALL_EXPR around an ADDR_EXPR around a function.  */
-
+      tree alloc_fn;
+      tree call_expr;
+
+      /* Find the allocation function that is being called. */
+      call_expr = placement;
+      /* Sometimes we have a COMPOUND_EXPR, rather than a simple
+        CALL_EXPR. */
+      while (TREE_CODE (call_expr) == COMPOUND_EXPR)
+       call_expr = TREE_OPERAND (call_expr, 1);
       /* Extract the function.  */
-      argtypes = TREE_OPERAND (TREE_OPERAND (placement, 0), 0);
+      alloc_fn = get_callee_fndecl (call_expr);
+      my_friendly_assert (alloc_fn != NULL_TREE, 20020327);
       /* Then the second parm type.  */
-      argtypes = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (argtypes)));
-
+      argtypes = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (alloc_fn)));
       /* Also the second argument.  */
-      args = TREE_CHAIN (TREE_OPERAND (placement, 1));
+      args = TREE_CHAIN (TREE_OPERAND (call_expr, 1));
     }
   else
     {
index 7be0736..f660231 100644 (file)
@@ -1,3 +1,7 @@
+2002-03-27  Mark Mitchell  <mark@codesourcery.com>
+
+       * g++.dg/init/new2.C: New test.
+       
 2002-03-26  Richard Henderson  <rth@redhat.com>
 
        * gcc.dg/pragma-re-2.c: Avoid empty source file warning.
diff --git a/gcc/testsuite/g++.dg/init/new2.C b/gcc/testsuite/g++.dg/init/new2.C
new file mode 100644 (file)
index 0000000..572cb28
--- /dev/null
@@ -0,0 +1,18 @@
+// Origin: asharji@uwaterloo.ca
+
+// { dg-do compile }
+// { dg-options "-fvolatile" }
+
+class bar {
+  public :
+    bar() { }
+    void * operator new ( __SIZE_TYPE__ , void * storage ) 
+     { return (void *)1;}
+};
+
+class foo {
+  public:
+    void mem ( ) {
+        new ( 0 ) bar;
+    }
+};