aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2003-01-13 20:08:58 +0000
committerDaniel Jacobowitz <drow@false.org>2003-01-13 20:08:58 +0000
commit973ccf8b5520ba49010e7d92ab8b2ff71fbd7e8b (patch)
tree1d39b5a5358b3288e8e2f796894c437105051a53 /gdb
parenta1fb14a2c2feb11e1d3ab0be56d7962914a7133b (diff)
downloadgdb-973ccf8b5520ba49010e7d92ab8b2ff71fbd7e8b.zip
gdb-973ccf8b5520ba49010e7d92ab8b2ff71fbd7e8b.tar.gz
gdb-973ccf8b5520ba49010e7d92ab8b2ff71fbd7e8b.tar.bz2
Fix PR gdb/872.
* gdbtypes.c (init_type): Mark "char" as TYPE_FLAG_NOSIGN. (integer_types_same_name_p): New function. (rank_one_type): Use it. * stabsread.c (read_range_type): Mark "char" as TYPE_FLAG_NOSIGN.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/gdbtypes.c56
-rw-r--r--gdb/stabsread.c2
3 files changed, 59 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 21ad8bc..de950fe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2003-01-13 Daniel Jacobowitz <drow@mvista.com>
+ Fix PR gdb/872.
+ * gdbtypes.c (init_type): Mark "char" as TYPE_FLAG_NOSIGN.
+ (integer_types_same_name_p): New function.
+ (rank_one_type): Use it.
+ * stabsread.c (read_range_type): Mark "char" as TYPE_FLAG_NOSIGN.
+
+2003-01-13 Daniel Jacobowitz <drow@mvista.com>
+
* Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
variables.
(main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2a8817d..dc1e48a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1874,6 +1874,9 @@ init_type (enum type_code code, int length, int flags, char *name,
/* C++ fancies. */
+ if (name && strcmp (name, "char") == 0)
+ TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
+
if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
{
INIT_CPLUS_SPECIFIC (type);
@@ -2441,6 +2444,43 @@ rank_function (struct type **parms, int nparms, struct type **args, int nargs)
return bv;
}
+/* Compare the names of two integer types, assuming that any sign
+ qualifiers have been checked already. We do it this way because
+ there may be an "int" in the name of one of the types. */
+
+static int
+integer_types_same_name_p (const char *first, const char *second)
+{
+ int first_p, second_p;
+
+ /* If both are shorts, return 1; if neither is a short, keep checking. */
+ first_p = (strstr (first, "short") != NULL);
+ second_p = (strstr (second, "short") != NULL);
+ if (first_p && second_p)
+ return 1;
+ if (first_p || second_p)
+ return 0;
+
+ /* Likewise for long. */
+ first_p = (strstr (first, "long") != NULL);
+ second_p = (strstr (second, "long") != NULL);
+ if (first_p && second_p)
+ return 1;
+ if (first_p || second_p)
+ return 0;
+
+ /* Likewise for char. */
+ first_p = (strstr (first, "char") != NULL);
+ second_p = (strstr (second, "char") != NULL);
+ if (first_p && second_p)
+ return 1;
+ if (first_p || second_p)
+ return 0;
+
+ /* They must both be ints. */
+ return 1;
+}
+
/* Compare one type (PARM) for compatibility with another (ARG).
* PARM is intended to be the parameter type of a function; and
* ARG is the supplied argument's type. This function tests if
@@ -2557,16 +2597,19 @@ rank_one_type (struct type *parm, struct type *arg)
{
if (TYPE_UNSIGNED (arg))
{
- if (!strcmp_iw (TYPE_NAME (parm), TYPE_NAME (arg)))
- return 0; /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
- else if (!strcmp_iw (TYPE_NAME (arg), "int") && !strcmp_iw (TYPE_NAME (parm), "long"))
+ /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
+ if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
+ return 0;
+ else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
+ && integer_types_same_name_p (TYPE_NAME (parm), "long"))
return INTEGER_PROMOTION_BADNESS; /* unsigned int -> unsigned long */
else
return INTEGER_COERCION_BADNESS; /* unsigned long -> unsigned int */
}
else
{
- if (!strcmp_iw (TYPE_NAME (arg), "long") && !strcmp_iw (TYPE_NAME (parm), "int"))
+ if (integer_types_same_name_p (TYPE_NAME (arg), "long")
+ && integer_types_same_name_p (TYPE_NAME (parm), "int"))
return INTEGER_COERCION_BADNESS; /* signed long -> unsigned int */
else
return INTEGER_CONVERSION_BADNESS; /* signed int/long -> unsigned int/long */
@@ -2574,9 +2617,10 @@ rank_one_type (struct type *parm, struct type *arg)
}
else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
{
- if (!strcmp_iw (TYPE_NAME (parm), TYPE_NAME (arg)))
+ if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
return 0;
- else if (!strcmp_iw (TYPE_NAME (arg), "int") && !strcmp_iw (TYPE_NAME (parm), "long"))
+ else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
+ && integer_types_same_name_p (TYPE_NAME (parm), "long"))
return INTEGER_PROMOTION_BADNESS;
else
return INTEGER_COERCION_BADNESS;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 7d4459e..135ff83 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -4930,7 +4930,7 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
/* Special case: char is defined (Who knows why) as a subrange of
itself with range 0-127. */
else if (self_subrange && n2 == 0 && n3 == 127)
- return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
+ return init_type (TYPE_CODE_INT, 1, TYPE_FLAG_NOSIGN, NULL, objfile);
/* We used to do this only for subrange of self or subrange of int. */
else if (n2 == 0)