aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-10-06 16:13:35 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-10-06 16:13:35 +0000
commit2f608a3a9752190066db4996ab855b423033b580 (patch)
tree40188e72ff610f9cc5a1eeb167481b0eb2ab4309 /gdb/dwarf2read.c
parentaa2e2d8d772c0ece5b6c4685228c159979841a5d (diff)
downloadgdb-2f608a3a9752190066db4996ab855b423033b580.zip
gdb-2f608a3a9752190066db4996ab855b423033b580.tar.gz
gdb-2f608a3a9752190066db4996ab855b423033b580.tar.bz2
gdb:
* dwarf2read.c (read_tag_const_type): Handle const arrays. gdb/testsuite: * gdb.base/constvars.c (logical, lugged, luck, lunar, lumen, lurk, lush, lynx) New constant. * gdb.base/constvars.exp: Test const array types. * gdb.dwarf2/dw2-strp.exp: Add const qualifier for ptype tests.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bf36e01..02304cb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7607,6 +7607,29 @@ read_tag_const_type (struct die_info *die, struct dwarf2_cu *cu)
if (cv_type)
return cv_type;
+ /* In case the const qualifier is applied to an array type, the element type
+ is so qualified, not the array type (section 6.7.3 of C99). */
+ if (TYPE_CODE (base_type) == TYPE_CODE_ARRAY)
+ {
+ struct type *el_type, *inner_array;
+
+ base_type = copy_type (base_type);
+ inner_array = base_type;
+
+ while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
+ {
+ TYPE_TARGET_TYPE (inner_array) =
+ copy_type (TYPE_TARGET_TYPE (inner_array));
+ inner_array = TYPE_TARGET_TYPE (inner_array);
+ }
+
+ el_type = TYPE_TARGET_TYPE (inner_array);
+ TYPE_TARGET_TYPE (inner_array) =
+ make_cv_type (1, TYPE_VOLATILE (el_type), el_type, NULL);
+
+ return set_die_type (die, base_type, cu);
+ }
+
cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
return set_die_type (die, cv_type, cu);
}