gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 18 Feb 2011 19:10:48 +0000 (19:10 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 18 Feb 2011 19:10:48 +0000 (19:10 +0000)
* cp-support.c (make_symbol_overload_list_namespace): Do not call
make_symbol_overload_list_block with NULL BLOCK.
* valarith.c (unop_user_defined_p): Resolve also TYPE_CODE_TYPEDEF.

gdb/testsuite/
* gdb.cp/typedef-operator.exp: New file.
* gdb.cp/typedef-operator.cc: New file.

gdb/ChangeLog
gdb/cp-support.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/typedef-operator.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/typedef-operator.exp [new file with mode: 0644]
gdb/valarith.c

index bd987d61e7d06d13321e3d169f50e4d00bd29b0c..1f08f84234ba441b55cc10fc471282da46053f63 100644 (file)
@@ -1,3 +1,10 @@
+2011-02-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
+           Tom Tromey  <tromey@redhat.com>
+
+       * cp-support.c (make_symbol_overload_list_namespace): Do not call
+       make_symbol_overload_list_block with NULL BLOCK.
+       * valarith.c (unop_user_defined_p): Resolve also TYPE_CODE_TYPEDEF.
+
 2011-02-18  Pedro Alves  <pedro@codesourcery.com>
 
        * breakpoint.c (get_number_trailer): No longer accept a NULL PP.
index afa5c21fe89fd00017f6ddc04f0e7e403f9af0a8..bb1563f3240e8f17d32e91246d841da75b63e3e9 100644 (file)
@@ -778,11 +778,13 @@ make_symbol_overload_list_namespace (const char *func_name,
 
   /* Look in the static block.  */
   block = block_static_block (get_selected_block (0));
-  make_symbol_overload_list_block (name, block);
+  if (block)
+    make_symbol_overload_list_block (name, block);
 
   /* Look in the global block.  */
   block = block_global_block (block);
-  make_symbol_overload_list_block (name, block);
+  if (block)
+    make_symbol_overload_list_block (name, block);
 
 }
 
index 7aaf370002135ebd2168a4d058069283ae022c8d..8ef2fcdd9cde36787e41c0006fb340d9203555f5 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.cp/typedef-operator.exp: New file.
+       * gdb.cp/typedef-operator.cc: New file.
+
 2011-02-17  Michael Snyder  <msnyder@vmware.com>
 
        * gdb.threads/thread-find.exp: Fix regular expressions.
diff --git a/gdb/testsuite/gdb.cp/typedef-operator.cc b/gdb/testsuite/gdb.cp/typedef-operator.cc
new file mode 100644 (file)
index 0000000..1cfedaa
--- /dev/null
@@ -0,0 +1,31 @@
+/* This test case is part of GDB, the GNU debugger.
+
+   Copyright 2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+class C
+{
+public:
+  int operator* () { return 42; }
+};
+typedef C D;
+
+D u;
+D &v = u;
+
+int main ()
+{
+  return *v;
+}
diff --git a/gdb/testsuite/gdb.cp/typedef-operator.exp b/gdb/testsuite/gdb.cp/typedef-operator.exp
new file mode 100644 (file)
index 0000000..64ecef7
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+if {[skip_cplus_tests]} { continue }
+
+set testfile "typedef-operator"
+if [prepare_for_testing $testfile $testfile $testfile.cc {c++ debug}] {
+    return -1
+}
+
+gdb_test_no_output "set language c++"
+
+gdb_test "p *u" {You can't do that without a process to debug.} "test crash"
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_test "p *v" " = 42" "test typedef"
index 787fc69390c7753dd7503203ee1b2232cc31c5d9..68f649f3c078ce13820d4293f21e724189675f5b 100644 (file)
@@ -315,15 +315,9 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1)
   if (op == UNOP_ADDR)
     return 0;
   type1 = check_typedef (value_type (arg1));
-  for (;;)
-    {
-      if (TYPE_CODE (type1) == TYPE_CODE_STRUCT)
-       return 1;
-      else if (TYPE_CODE (type1) == TYPE_CODE_REF)
-       type1 = TYPE_TARGET_TYPE (type1);
-      else
-       return 0;
-    }
+  if (TYPE_CODE (type1) == TYPE_CODE_REF)
+    type1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  return TYPE_CODE (type1) == TYPE_CODE_STRUCT;
 }
 
 /* Try to find an operator named OPERATOR which takes NARGS arguments
This page took 0.044615 seconds and 4 git commands to generate.