aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-12-21 18:19:17 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2017-12-21 18:21:45 -0500
commita8d2e5856f87a658d69018fe1ccd56482eebdd59 (patch)
treec0be42e8971a0df710ad9c19ff59a2fb53fba725 /gdb/target-descriptions.c
parentRemove write-only assignment in rs6000-tdep.c (diff)
downloadbinutils-gdb-a8d2e5856f87a658d69018fe1ccd56482eebdd59.tar.gz
binutils-gdb-a8d2e5856f87a658d69018fe1ccd56482eebdd59.tar.bz2
binutils-gdb-a8d2e5856f87a658d69018fe1ccd56482eebdd59.zip
Do not emit "field_type" var if not needed on "maint print c-tdesc"
While fiddling a bit with -Wunused-variable, Sergio noticed that "maint print c-tdesc" was always generating code for the "tdesc_type *field_type" variable, even when it wasn't used. This is caught by GCC when using -Wunused-variable, of course. This patch changes the print_c_tdesc class to only output the field declaration when we actually need it. It shouldn't be necessary to do the same with the other variable declarations (type_with_fields and element_type), because they are always if they are declared. The C files in features/ are regenerated, some declarations of field_type are removed, as expected, while some others move to where they are used for the first time. gdb/ChangeLog: * target-descriptions.c (print_c_tdesc) <visit>: Don't output field_type declaration, use printf_field_type_assignment instead. <printf_field_type_assignment>: New method. * features/aarch64-core.c, features/aarch64-fpu.c features/arc-arcompact.c, features/arc-v2.c, features/arm/arm-with-iwmmxt.c, features/i386/32bit-core.c, features/i386/32bit-mpx.c, features/i386/32bit-sse.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-mpx.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/or1k.c, features/rs6000/powerpc-7400.c, features/rs6000/powerpc-altivec32.c, features/rs6000/powerpc-altivec32l.c, features/rs6000/powerpc-altivec64.c, features/rs6000/powerpc-altivec64l.c, features/rs6000/powerpc-cell32l.c, features/rs6000/powerpc-cell64l.c, features/rs6000/powerpc-isa205-altivec32l.c, features/rs6000/powerpc-isa205-altivec64l.c, features/rs6000/powerpc-isa205-vsx32l.c, features/rs6000/powerpc-isa205-vsx64l.c, features/rs6000/powerpc-vsx32.c, features/rs6000/powerpc-vsx32l.c, features/rs6000/powerpc-vsx64.c, features/rs6000/powerpc-vsx64l.c, features/s390-gs-linux64.c, features/s390-tevx-linux64.c, features/s390-vx-linux64.c, features/s390x-gs-linux64.c, features/s390x-tevx-linux64.c, features/s390x-vx-linux64.c: Re-generate.
Diffstat (limited to 'gdb/target-descriptions.c')
-rw-r--r--gdb/target-descriptions.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 88ac55f404a..5dcc4c4c5c0 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1894,13 +1894,6 @@ public:
m_printed_type_with_fields = true;
}
- if (!type->fields.empty ()
- && !m_printed_field_type)
- {
- printf_unfiltered (" tdesc_type *field_type;\n");
- m_printed_field_type = true;
- }
-
switch (type->kind)
{
case TDESC_TYPE_STRUCT:
@@ -1949,8 +1942,8 @@ public:
}
else
{
- printf_unfiltered
- (" field_type = tdesc_named_type (feature, \"%s\");\n",
+ printf_field_type_assignment
+ ("tdesc_named_type (feature, \"%s\");\n",
type_name);
printf_unfiltered
(" tdesc_add_typed_bitfield (type_with_fields, \"%s\","
@@ -1962,10 +1955,8 @@ public:
{
gdb_assert (f.end == -1);
gdb_assert (type->kind == TDESC_TYPE_STRUCT);
- printf_unfiltered
- (" field_type = tdesc_named_type (feature,"
- " \"%s\");\n",
- type_name);
+ printf_field_type_assignment
+ ("tdesc_named_type (feature, \"%s\");\n", type_name);
printf_unfiltered
(" tdesc_add_field (type_with_fields, \"%s\", field_type);\n",
f.name.c_str ());
@@ -1978,9 +1969,8 @@ public:
type->name.c_str ());
for (const tdesc_type_field &f : type->fields)
{
- printf_unfiltered
- (" field_type = tdesc_named_type (feature, \"%s\");\n",
- f.type->name.c_str ());
+ printf_field_type_assignment
+ ("tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ());
printf_unfiltered
(" tdesc_add_field (type_with_fields, \"%s\", field_type);\n",
f.name.c_str ());
@@ -2018,6 +2008,25 @@ protected:
std::string m_filename_after_features;
private:
+
+ /* Print an assignment to the field_type variable. Print the declaration
+ of field_type if that has not been done yet. */
+ void printf_field_type_assignment (const char *fmt, ...)
+ {
+ if (!m_printed_field_type)
+ {
+ printf_unfiltered (" tdesc_type *field_type;\n");
+ m_printed_field_type = true;
+ }
+
+ printf_unfiltered (" field_type = ");
+
+ va_list args;
+ va_start (args, fmt);
+ vprintf_unfiltered (fmt, args);
+ va_end (args);
+ }
+
char *m_function;
/* Did we print "struct tdesc_type *element_type;" yet? */