]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/10527 (confused error message with "new int()" parameter initializer)
authorMark Mitchell <mark@codesourcery.com>
Tue, 29 Apr 2003 20:17:00 +0000 (20:17 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 29 Apr 2003 20:17:00 +0000 (20:17 +0000)
PR c++/10527
* error.c (dump_expr): Correctly handling of NEW_EXPR.4

PR c++/10527
* g++.dg/init/new7.C: New test.

From-SVN: r66247

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

index 98d9fdbdc67ef4342d2e241ac8908c17d21e885b..3a65705a2898e1392c19b0059e1514ebac72554f 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10527
+       * error.c (dump_expr): Correctly handling of NEW_EXPR.4
+
 2003-04-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * call.c (build_operator_new_call): Fix typo.
index f836ecc59ec1d6c4c8443365adedc39e77d25f0a..3e299de57c861ab9b93c900b388937e89b56a624 100644 (file)
@@ -1603,6 +1603,7 @@ dump_expr (tree t, int flags)
     case NEW_EXPR:
       {
        tree type = TREE_OPERAND (t, 1);
+       tree init = TREE_OPERAND (t, 2);
        if (NEW_EXPR_USE_GLOBAL (t))
          print_scope_operator (scratch_buffer);
        output_add_string (scratch_buffer, "new ");
@@ -1619,10 +1620,17 @@ dump_expr (tree t, int flags)
                                            TREE_OPERAND (type, 1),
                                            integer_one_node))));
        dump_type (type, flags);
-       if (TREE_OPERAND (t, 2))
+       if (init)
          {
            print_left_paren (scratch_buffer);
-           dump_expr_list (TREE_OPERAND (t, 2), flags);
+           if (TREE_CODE (init) == TREE_LIST)
+             dump_expr_list (init, flags);
+           else if (init == void_zero_node)
+             /* This representation indicates an empty initializer,
+                e.g.: "new int()".  */
+             ;
+           else
+             dump_expr (init, flags);
            print_right_paren (scratch_buffer);
          }
       }
index 45326b207d388e7aac3109862efbdb46a31ff43d..0a670f8797a4c6b768aac48d1c9495b38eb29b66 100644 (file)
@@ -1,7 +1,12 @@
+2003-04-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10527
+       * g++.dg/init/new7.C: New test.
+
 2003-04-29  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/ext/desig1.C: New test.
-       * g++.dg/ext/init1.C: Likewise.
+       * g++.dg/ext/init1.C: Update.
 
        * g++.old-deja/g++.pt/deduct5.C: Remove unnecessary initializer.
 
diff --git a/gcc/testsuite/g++.dg/init/new7.C b/gcc/testsuite/g++.dg/init/new7.C
new file mode 100644 (file)
index 0000000..e07d226
--- /dev/null
@@ -0,0 +1,7 @@
+template <class T>
+ struct Foo
+ {};
+ template <class T>
+ void Foo<T>::NON_EXISTENT(int* val = new int()) {} // { dg-error "" }
This page took 0.115572 seconds and 5 git commands to generate.