Skip to content

Commit bc9a555

Browse files
committed
gdb/
Fix const/volatile qualifiers of C++ types, PR c++/12328. * c-typeprint.c (c_type_print_args): Update the function comment. New variable param_type, initialize it. Remove const/volatile qualifiers for language_cplus and !show_artificial. Use param_type. gdb/testsuite/ Fix const/volatile qualifiers of C++ types, PR c++/12328. * gdb.cp/overload-const.exp: New file. * gdb.cp/overload-const.cc: New file.
1 parent 93b55aa commit bc9a555

File tree

5 files changed

+94
-7
lines changed

5 files changed

+94
-7
lines changed

gdb/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2011-02-13 Jan Kratochvil <[email protected]>
2+
3+
Fix const/volatile qualifiers of C++ types, PR c++/12328.
4+
* c-typeprint.c (c_type_print_args): Update the function comment. New
5+
variable param_type, initialize it. Remove const/volatile qualifiers
6+
for language_cplus and !show_artificial. Use param_type.
7+
18
2011-02-13 Jan Kratochvil <[email protected]>
29

310
* symtab.c (find_pc_sect_line): New variable objfile, initialize it

gdb/c-typeprint.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,12 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
388388
/* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
389389
or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
390390
in non-static methods, are displayed if SHOW_ARTIFICIAL is
391-
non-zero. LANGUAGE is the language in which TYPE was defined.
392-
This is a necessary evil since this code is used by the C, C++, and
393-
Java backends. */
391+
non-zero. If SHOW_ARTIFICIAL is zero and LANGUAGE is language_cplus
392+
the topmost parameter types get removed their possible const and volatile
393+
qualifiers to match demangled linkage name parameters part of such function
394+
type. LANGUAGE is the language in which TYPE was defined. This is
395+
a necessary evil since this code is used by the C, C++, and Java backends.
396+
*/
394397

395398
void
396399
c_type_print_args (struct type *type, struct ui_file *stream,
@@ -406,6 +409,8 @@ c_type_print_args (struct type *type, struct ui_file *stream,
406409

407410
for (i = 0; i < TYPE_NFIELDS (type); i++)
408411
{
412+
struct type *param_type;
413+
409414
if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
410415
continue;
411416

@@ -415,12 +420,24 @@ c_type_print_args (struct type *type, struct ui_file *stream,
415420
wrap_here (" ");
416421
}
417422

423+
param_type = TYPE_FIELD_TYPE (type, i);
424+
425+
if (language == language_cplus && !show_artificial)
426+
{
427+
/* C++ standard, 13.1 Overloadable declarations, point 3, item:
428+
- Parameter declarations that differ only in the presence or
429+
absence of const and/or volatile are equivalent.
430+
431+
And the const/volatile qualifiers are not present in the mangled
432+
names as produced by GCC. */
433+
434+
param_type = make_cv_type (0, 0, param_type, NULL);
435+
}
436+
418437
if (language == language_java)
419-
java_print_type (TYPE_FIELD_TYPE (type, i),
420-
"", stream, -1, 0);
438+
java_print_type (param_type, "", stream, -1, 0);
421439
else
422-
c_print_type (TYPE_FIELD_TYPE (type, i),
423-
"", stream, -1, 0);
440+
c_print_type (param_type, "", stream, -1, 0);
424441
printed_any = 1;
425442
}
426443

gdb/testsuite/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2011-02-13 Jan Kratochvil <[email protected]>
2+
3+
Fix const/volatile qualifiers of C++ types, PR c++/12328.
4+
* gdb.cp/overload-const.exp: New file.
5+
* gdb.cp/overload-const.cc: New file.
6+
17
2011-02-08 Ulrich Weigand <[email protected]>
28

39
* gdb.opencl/callfuncs.cl: New file.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* This test case is part of GDB, the GNU debugger.
2+
3+
Copyright 2011 Free Software Foundation, Inc.
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+
class myclass
19+
{
20+
public:
21+
static void func(const int aa) {}
22+
};
23+
24+
int
25+
main ()
26+
{
27+
myclass::func (42);
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2011 Free Software Foundation, Inc.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
# This file is part of the gdb testsuite.
17+
18+
if {[skip_cplus_tests]} { continue }
19+
20+
set testfile "overload-const"
21+
if [prepare_for_testing $testfile $testfile $testfile.cc {c++ debug}] {
22+
return -1
23+
}
24+
25+
gdb_test_no_output "set language c++"
26+
27+
if [gdb_breakpoint "myclass::func"] {
28+
pass "setting breakpoint at myclass::func"
29+
}

0 commit comments

Comments
 (0)