Return unique_xmalloc_ptr for generate_c_for_variable_locations
[deliverable/binutils-gdb.git] / gdb / compile / compile-c-types.c
index 853342952d9c0369ad677c44ac1ad89fbaf486d3..212cfe66bef4b478f721d3b474a847ab84cdb72c 100644 (file)
@@ -1,6 +1,6 @@
 /* Convert types from GDB to GCC
 
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -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.  */
This page took 0.024138 seconds and 4 git commands to generate.