/* Support for printing C and C++ types for GDB, the GNU debugger.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
/* Print "const", "volatile", or address space modifiers. */
static void c_type_print_modifier (struct type *,
struct ui_file *,
- int, int);
+ int, int, enum language);
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level, enum language language,
if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
fputs_styled (varstring, function_name_style.style (), stream);
else
- fputs_filtered (varstring, stream);
+ fputs_styled (varstring, variable_name_style.style (), stream);
/* For demangled function names, we have the arglist as part of
the name, so don't print an additional pair of ()'s. */
fprintf_filtered (stream, " volatile");
if (TYPE_RESTRICT (domain))
- fprintf_filtered (stream, " restrict");
+ fprintf_filtered (stream, (language == language_cplus
+ ? " __restrict__"
+ : " restrict"));
if (TYPE_ATOMIC (domain))
fprintf_filtered (stream, " _Atomic");
stream, show, 1, 1, language, flags,
podata);
fprintf_filtered (stream, "*");
- c_type_print_modifier (type, stream, 1, need_post_space);
+ c_type_print_modifier (type, stream, 1, need_post_space, language);
break;
case TYPE_CODE_MEMBERPTR:
stream, show, 1, 0, language, flags,
podata);
fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
- c_type_print_modifier (type, stream, 1, need_post_space);
+ c_type_print_modifier (type, stream, 1, need_post_space, language);
break;
case TYPE_CODE_METHOD:
static void
c_type_print_modifier (struct type *type, struct ui_file *stream,
- int need_pre_space, int need_post_space)
+ int need_pre_space, int need_post_space,
+ enum language language)
{
int did_print_modifier = 0;
const char *address_space_id;
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
- fprintf_filtered (stream, "restrict");
+ fprintf_filtered (stream, (language == language_cplus
+ ? "__restrict__"
+ : "restrict"));
did_print_modifier = 1;
}
hash_holder.reset (local_flags.local_typedefs);
}
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1, language);
if (TYPE_CODE (type) == TYPE_CODE_UNION)
fprintf_filtered (stream, "union ");
else if (TYPE_DECLARED_CLASS (type))
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1, language);
/* If we have "typedef struct foo {. . .} bar;" do we want to
print it as "struct foo" or as "bar"? Pick the latter for
break;
case TYPE_CODE_ENUM:
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1, language);
fprintf_filtered (stream, "enum ");
if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_styled (TYPE_FIELD_NAME (type, i),
+ variable_name_style.style (), stream);
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
fprintf_filtered (stream, " = %s",
local_flags.local_typedefs = NULL;
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1, language);
fprintf_filtered (stream, "flag ");
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
type name, then complain. */
if (TYPE_NAME (type) != NULL)
{
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1, language);
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
}
else