aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2009-06-23 16:26:05 +0000
committerTom Tromey <tromey@redhat.com>2009-06-23 16:26:05 +0000
commit85e306ed0eb2fb5032d459a13cfd345edf1bb2aa (patch)
tree718a1bbdb8b9c3608901375eb80024b749422ffb /gdb/c-lang.c
parent3188b0706d4d68b6cd4df669ca4557fc2f87736a (diff)
downloadgdb-85e306ed0eb2fb5032d459a13cfd345edf1bb2aa.zip
gdb-85e306ed0eb2fb5032d459a13cfd345edf1bb2aa.tar.gz
gdb-85e306ed0eb2fb5032d459a13cfd345edf1bb2aa.tar.bz2
gdb
PR gdb/10309: * c-lang.c (classify_type): Iterate over typedefs. * c-valprint.c (textual_element_type): Iterate over typedefs. gdb/testsuite * gdb.base/charset.exp (test_combination): Regression test. * gdb.base/charset.c (my_wchar_t): New typedef. (myvar): New global. (main): Set myvar.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 898ae8d..5718143 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -77,9 +77,12 @@ classify_type (struct type *elttype, const char **encoding)
struct type *saved_type;
enum c_string_type result;
- /* We do one or two passes -- one on ELTTYPE, and then maybe a
- second one on a typedef target. */
- do
+ /* We loop because ELTTYPE may be a typedef, and we want to
+ successively peel each typedef until we reach a type we
+ understand. We don't use CHECK_TYPEDEF because that will strip
+ all typedefs at once -- but in C, wchar_t is itself a typedef, so
+ that would do the wrong thing. */
+ while (elttype)
{
char *name = TYPE_NAME (elttype);
@@ -107,10 +110,22 @@ classify_type (struct type *elttype, const char **encoding)
goto done;
}
- saved_type = elttype;
- CHECK_TYPEDEF (elttype);
+ if (TYPE_CODE (elttype) != TYPE_CODE_TYPEDEF)
+ break;
+
+ /* Call for side effects. */
+ check_typedef (elttype);
+
+ if (TYPE_TARGET_TYPE (elttype))
+ elttype = TYPE_TARGET_TYPE (elttype);
+ else
+ {
+ /* Perhaps check_typedef did not update the target type. In
+ this case, force the lookup again and hope it works out.
+ It never will for C, but it might for C++. */
+ CHECK_TYPEDEF (elttype);
+ }
}
- while (elttype != saved_type);
/* Punt. */
result = C_CHAR;