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);
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;
&& w != LCST ('8')
&& w != LCST ('9'))))
{
+ gdb_wchar_t wchar = w;
+
if (w == gdb_btowc (quoter) || w == LCST ('\\'))
obstack_grow_wstr (output, LCST ("\\"));
- obstack_grow (output, &w, sizeof (gdb_wchar_t));
+ obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
}
else
{
switch (dest_type & ~C_CHAR)
{
case C_STRING:
- type = language_string_char_type (current_language,
- current_gdbarch);
+ type = language_string_char_type (exp->language_defn,
+ exp->gdbarch);
break;
case C_WIDE_STRING:
- type = lookup_typename ("wchar_t", NULL, 0);
+ type = lookup_typename (exp->language_defn, exp->gdbarch,
+ "wchar_t", NULL, 0);
break;
case C_STRING_16:
- type = lookup_typename ("char16_t", NULL, 0);
+ type = lookup_typename (exp->language_defn, exp->gdbarch,
+ "char16_t", NULL, 0);
break;
case C_STRING_32:
- type = lookup_typename ("char32_t", NULL, 0);
+ type = lookup_typename (exp->language_defn, exp->gdbarch,
+ "char32_t", NULL, 0);
break;
default:
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
if ((dest_type & C_CHAR) != 0)
result = allocate_value (type);
else
- result = value_typed_string ("", 0, type);
+ result = value_cstring ("", 0, type);
do_cleanups (cleanup);
return result;
}
/* Write the terminating character. */
for (i = 0; i < TYPE_LENGTH (type); ++i)
obstack_1grow (&output, 0);
- result = value_typed_string (obstack_base (&output),
- obstack_object_size (&output),
- type);
+ result = value_cstring (obstack_base (&output),
+ obstack_object_size (&output),
+ type);
}
do_cleanups (cleanup);
return result;