From 80b23b6aeb1ae33fd4e4365b9a075c18fd1407f7 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 29 Jan 2011 10:30:20 +0000 Subject: [PATCH] gdb/ Fix crash. * valops.c (compare_parameters): Verify TYPE_NFIELDS before touching TYPE_FIELD_ARTIFICIAL. gdb/testsuite/ * gdb.cp/noparam.exp: New file. * gdb.cp/noparam.cc: New file. --- gdb/ChangeLog | 6 ++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.cp/noparam.cc | 29 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.cp/noparam.exp | 21 +++++++++++++++++++++ gdb/valops.c | 2 +- 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.cp/noparam.cc create mode 100644 gdb/testsuite/gdb.cp/noparam.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d65f43b..a164d82 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-01-29 Jan Kratochvil + + Fix crash. + * valops.c (compare_parameters): Verify TYPE_NFIELDS before + touching TYPE_FIELD_ARTIFICIAL. + 2011-01-28 Richard Earnshaw * MAINTAINERS: Move myself from Responsible Maintainers to Authorized diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1e7543e..1b63bff 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-01-29 Jan Kratochvil + + * gdb.cp/noparam.exp: New file. + * gdb.cp/noparam.cc: New file. + 2011-01-28 Pedro Alves * gdb.trace/tfile.exp: Test that with no traceframe selected, diff --git a/gdb/testsuite/gdb.cp/noparam.cc b/gdb/testsuite/gdb.cp/noparam.cc new file mode 100644 index 0000000..6306650 --- /dev/null +++ b/gdb/testsuite/gdb.cp/noparam.cc @@ -0,0 +1,29 @@ +/* This testcase 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 . */ + +class C +{ +public: + static void m () {} +}; + +int +main () +{ + C::m (); + return 0; +} diff --git a/gdb/testsuite/gdb.cp/noparam.exp b/gdb/testsuite/gdb.cp/noparam.exp new file mode 100644 index 0000000..ce68e1b --- /dev/null +++ b/gdb/testsuite/gdb.cp/noparam.exp @@ -0,0 +1,21 @@ +# 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 . + +if { [prepare_for_testing noparam.exp "noparam" "noparam.cc" {debug c++}] } { + return -1 +} + +# Check if GDB does not crash. +gdb_test "p C::m (int)" "no member function matches that type instantiation" diff --git a/gdb/valops.c b/gdb/valops.c index 19d5238..24c2269 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3097,7 +3097,7 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial) { int start = 0; - if (TYPE_FIELD_ARTIFICIAL (t1, 0)) + if (TYPE_NFIELDS (t1) > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0)) ++start; /* If skipping artificial fields, find the first real field -- 2.7.4