make is_scalar_type non-static and use it in ada-lang.c
authorJoel Brobecker <brobecker@adacore.com>
Fri, 9 Oct 2015 21:14:43 +0000 (14:14 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Fri, 9 Oct 2015 21:32:23 +0000 (14:32 -0700)
Just a small cleanup, to avoid code duplication...

gdb/ChangeLog:

        * gdbtypes.h (is_scalar_type): Add extern declaration.
        * gdbtypes.c (is_scalar_type): Make non-static.
        * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type
        to compute IS_SCALAR instead of doing it ourselves.

gdb/ChangeLog
gdb/ada-lang.c
gdb/gdbtypes.c
gdb/gdbtypes.h

index 06a0637860384b58a4f0378cdb23d27200867a3a..9787afeaa4b41b0cf259fe66ce1532c3c2c3da18 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-09  Joel Brobecker  <brobecker@adacore.com>
+
+       * gdbtypes.h (is_scalar_type): Add extern declaration.
+       * gdbtypes.c (is_scalar_type): Make non-static.
+       * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type
+       to compute IS_SCALAR instead of doing it ourselves.
+
 2015-10-09  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (ada_value_primitive_packed_val): Rework handling
index 2b2c47c933a9570dbbd18907b0eba3cfcef8660a..d9bbed9a9ebcb0b200b6587f887d088fd77b8871 100644 (file)
@@ -2519,7 +2519,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
   gdb_byte *src;                /* First byte containing data to unpack */
   int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
   gdb_byte *unpacked;
-  int is_scalar;
+  const int is_scalar = is_scalar_type (type);
   const int is_big_endian = gdbarch_bits_big_endian (get_type_arch (type));
   gdb_byte *staging = NULL;
   int staging_len = 0;
@@ -2527,18 +2527,6 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
 
   type = ada_check_typedef (type);
 
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_ARRAY:
-    case TYPE_CODE_UNION:
-    case TYPE_CODE_STRUCT:
-      is_scalar = 0;
-      break;
-    default:
-      is_scalar = 1;
-      break;
-    }
-
   if (obj == NULL)
     src = (gdb_byte *) valaddr + offset;
   else
index b40655051d337d7eee45cb44b2e244aee0b914c1..919cac9f9abfa05864a08175af2096f98d58b18e 100644 (file)
@@ -2717,7 +2717,7 @@ is_integral_type (struct type *t)
 
 /* Return true if TYPE is scalar.  */
 
-static int
+int
 is_scalar_type (struct type *type)
 {
   type = check_typedef (type);
index 9c645698ed6705ca77fe833d0eeb64b4ee47b068..0828723447b26e65a224660ca953305e69bb7a74 100644 (file)
@@ -1912,6 +1912,8 @@ extern int can_dereference (struct type *);
 
 extern int is_integral_type (struct type *);
 
+extern int is_scalar_type (struct type *type);
+
 extern int is_scalar_type_recursive (struct type *);
 
 extern int class_or_union_p (const struct type *);
This page took 0.038135 seconds and 4 git commands to generate.