From: Ken Werner <ken@linux.vnet.ibm.com>
To: "Ulrich Weigand" <uweigand@de.ibm.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
brobecker@adacore.com, pedro@codesourcery.com,
gdb-patches@sourceware.org
Subject: Re: [patch] const array types
Date: Wed, 06 Oct 2010 15:38:00 -0000 [thread overview]
Message-ID: <201010061738.23786.ken@linux.vnet.ibm.com> (raw)
In-Reply-To: <201010051825.o95IP5I8010642@d12av02.megacenter.de.ibm.com>
[-- Attachment #1: Type: Text/Plain, Size: 574 bytes --]
On Tuesday, October 05, 2010 8:25:05 pm Ulrich Weigand wrote:
> Ken Werner wrote:
> > + return set_die_type (die, base_type, cu);;
>
> Extra semicolon.
Fixed.
> Do we need the local_compiler_xfail_check for these tests? If so, we'd
> need it before each of the tests; if not, we don't need it at all ...
Good point. Since const seems to be broken with gcc 2 -gstabs for primitives I
guess this is also the case for arrays. Therefore I've put the
local_compiler_xfail_check in front of each test.
Attached is a new version of the patch.
Ok to apply?
Thanks
Ken
[-- Attachment #2: const_array.patch --]
[-- Type: text/x-patch, Size: 4907 bytes --]
ChangeLog:
2010-10-06 Ken Werner <ken.werner@de.ibm.com>
* gdb/dwarf2read.c (read_tag_const_type): Handle const arrays.
testsuite/ChangeLog:
2010-10-06 Ken Werner <ken.werner@de.ibm.com>
* 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.
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.468
diff -p -u -r1.468 dwarf2read.c
--- gdb/dwarf2read.c 5 Oct 2010 03:10:28 -0000 1.468
+++ gdb/dwarf2read.c 6 Oct 2010 11:49:33 -0000
@@ -7607,6 +7607,29 @@ read_tag_const_type (struct die_info *di
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);
}
Index: gdb/testsuite/gdb.base/constvars.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/constvars.c,v
retrieving revision 1.4
diff -p -u -r1.4 constvars.c
--- gdb/testsuite/gdb.base/constvars.c 12 Nov 2009 19:35:26 -0000 1.4
+++ gdb/testsuite/gdb.base/constvars.c 6 Oct 2010 11:49:33 -0000
@@ -84,6 +84,16 @@ main (void)
float *const lissome = &leeway;
double *const locust = &legacy;
+ /* constant arrays */
+ const char logical[2] = {laconic, laconic};
+ const unsigned char lugged[2] = {laggard, laggard};
+ const short luck[2] = {lagoon, lagoon};
+ const unsigned short lunar[2] = {laity, laity};
+ const long lumen[2] = {lambent, lambent};
+ const unsigned long lurk[2] = {laminated, laminated};
+ const float lush[2] = {lampoon, lampoon};
+ const double lynx[2] = {languid, languid};
+
/* volatile variables */
volatile char vox = 'X';
Index: gdb/testsuite/gdb.base/constvars.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/constvars.exp,v
retrieving revision 1.23
diff -p -u -r1.23 constvars.exp
--- gdb/testsuite/gdb.base/constvars.exp 24 May 2010 22:03:59 -0000 1.23
+++ gdb/testsuite/gdb.base/constvars.exp 6 Oct 2010 11:49:33 -0000
@@ -253,6 +253,23 @@ proc do_constvar_tests {} {
gdb_test "ptype locust" "type = double \\* const"
local_compiler_xfail_check
+ gdb_test "ptype logical" "type = const char \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lugged" "type = const unsigned char \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype luck" "type = const short( int)? \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lunar" "type = const (unsigned short|short unsigned)( int)? \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lumen" "type = const long( int)? \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lurk" "type = const (unsigned long|long unsigned)( int)? \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lush" "type = const float \\\[2\\\]"
+ local_compiler_xfail_check
+ gdb_test "ptype lynx" "type = const double \\\[2\\\]"
+
+ local_compiler_xfail_check
local_compiler_xfail_check_2
gdb_test "ptype crass" "type = struct crass \{\[\r\n\]+\[\ \t\]+char \\* const ptr;\[\r\n\]+\}"
local_compiler_xfail_check
Index: gdb/testsuite/gdb.dwarf2/dw2-strp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-strp.exp,v
retrieving revision 1.4
diff -p -u -r1.4 dw2-strp.exp
--- gdb/testsuite/gdb.dwarf2/dw2-strp.exp 1 Jan 2010 07:32:02 -0000 1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-strp.exp 6 Oct 2010 11:49:33 -0000
@@ -49,7 +49,7 @@ gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test "p a_string" " = \"hello world!\\\\n\""
-gdb_test "ptype a_string" "type = char \\\[14\\\]"
+gdb_test "ptype a_string" "type = const char \\\[14\\\]"
gdb_test "p a_string2" " = \"hello world2\\\\n\""
-gdb_test "ptype a_string2" "type = char \\\[14\\\]"
+gdb_test "ptype a_string2" "type = const char \\\[14\\\]"
next prev parent reply other threads:[~2010-10-06 15:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-15 19:32 Ken Werner
2010-09-24 4:50 ` Jan Kratochvil
2010-09-24 15:38 ` Jan Kratochvil
2010-09-24 16:27 ` Joel Brobecker
2010-09-24 16:40 ` Pedro Alves
2010-09-24 23:00 ` Joel Brobecker
2010-09-24 18:36 ` Ken Werner
2010-10-05 18:25 ` Ulrich Weigand
2010-10-05 18:43 ` Joel Brobecker
2010-10-06 15:38 ` Ken Werner [this message]
2010-10-06 15:55 ` Ulrich Weigand
2010-10-06 16:18 ` Ken Werner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010061738.23786.ken@linux.vnet.ibm.com \
--to=ken@linux.vnet.ibm.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=pedro@codesourcery.com \
--cc=uweigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox