]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add libcc1 v1 compatibility to C compile feature
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 27 Apr 2018 18:17:02 +0000 (11:17 -0700)
committerKeith Seitz <keiths@redhat.com>
Fri, 27 Apr 2018 19:36:19 +0000 (12:36 -0700)
This patch adds v1 compatibiltiy to the C compile feature.  The only change
in v1 concerns the handling of integer types, which permits GDB to specify
the built-in name for the type.

As far as I know, the C frontend is still on v0, so this patch is purely
precautionary. [By default C++ compile uses the equivalent of the C
frontend's int_type and float_type (aka the "v1" versions).]

gdb/ChangeLog:

* compile/compile-c-types.c (convert_int, convert_float):
Update for C FE v1.

gdb/ChangeLog
gdb/compile/compile-c-types.c

index 2b9e55409931323d313242e34fb83caf745f5e32..55e640581a906e94f854260d943075e47e4d3165 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-27  Alexandre Oliva  <aoliva@redhat.com>
+
+       * compile/compile-c-types.c (convert_int, convert_float):
+       Update for C FE v1.
+
 2018-04-27  Tom Tromey  <tom@tromey.com>
 
        PR rust/22545:
index 19669a2edcc8724e020cb69bf99da3df1b3d38e1..212cfe66bef4b478f721d3b474a847ab84cdb72c 100644 (file)
@@ -273,9 +273,22 @@ convert_func (struct compile_c_instance *context, struct type *type)
 static gcc_type
 convert_int (struct compile_c_instance *context, struct type *type)
 {
-  return C_CTX (context)->c_ops->int_type_v0 (C_CTX (context),
-                                             TYPE_UNSIGNED (type),
-                                             TYPE_LENGTH (type));
+  if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+    {
+      if (TYPE_NOSIGN (type))
+       {
+         gdb_assert (TYPE_LENGTH (type) == 1);
+         return C_CTX (context)->c_ops->char_type (C_CTX (context));
+       }
+      return C_CTX (context)->c_ops->int_type (C_CTX (context),
+                                              TYPE_UNSIGNED (type),
+                                              TYPE_LENGTH (type),
+                                              TYPE_NAME (type));
+    }
+  else
+    return C_CTX (context)->c_ops->int_type_v0 (C_CTX (context),
+                                               TYPE_UNSIGNED (type),
+                                               TYPE_LENGTH (type));
 }
 
 /* Convert a floating-point type to its gcc representation.  */
@@ -283,8 +296,13 @@ convert_int (struct compile_c_instance *context, struct type *type)
 static gcc_type
 convert_float (struct compile_c_instance *context, struct type *type)
 {
-  return C_CTX (context)->c_ops->float_type_v0 (C_CTX (context),
-                                               TYPE_LENGTH (type));
+  if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+    return C_CTX (context)->c_ops->float_type (C_CTX (context),
+                                              TYPE_LENGTH (type),
+                                              TYPE_NAME (type));
+  else
+    return C_CTX (context)->c_ops->float_type_v0 (C_CTX (context),
+                                                 TYPE_LENGTH (type));
 }
 
 /* Convert the 'void' type to its gcc representation.  */