This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 04/13] Split rank_one_type_parm_int from rank_one_type
- From: Simon Marchi <simon dot marchi at efficios dot com>
- To: gdb-patches at sourceware dot org
- Cc: Simon Marchi <simon dot marchi at efficios dot com>
- Date: Wed, 27 Feb 2019 15:00:19 -0500
- Subject: [PATCH 04/13] Split rank_one_type_parm_int from rank_one_type
- Dkim-filter: OpenDKIM Filter v2.10.3 mail.efficios.com 2647F807D1
- References: <20190227200028.27360-1-simon.marchi@efficios.com>
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_int): New function extracted
from...
(rank_one_type): ... this.
---
gdb/gdbtypes.c | 173 +++++++++++++++++++++++++------------------------
1 file changed, 90 insertions(+), 83 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 45cd04815c..237969532b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3912,6 +3912,95 @@ rank_one_type_parm_func (struct type *parm, struct type *arg, struct value *valu
}
}
+/* rank_one_type helper for when PARM's type code is TYPE_CODE_INT. */
+
+static struct rank
+rank_one_type_parm_int (struct type *parm, struct type *arg, struct value *value)
+{
+ switch (TYPE_CODE (arg))
+ {
+ case TYPE_CODE_INT:
+ if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
+ {
+ /* Deal with signed, unsigned, and plain chars and
+ signed and unsigned ints. */
+ if (TYPE_NOSIGN (parm))
+ {
+ /* This case only for character types. */
+ if (TYPE_NOSIGN (arg))
+ return EXACT_MATCH_BADNESS; /* plain char -> plain char */
+ else /* signed/unsigned char -> plain char */
+ return INTEGER_CONVERSION_BADNESS;
+ }
+ else if (TYPE_UNSIGNED (parm))
+ {
+ if (TYPE_UNSIGNED (arg))
+ {
+ /* unsigned int -> unsigned int, or
+ unsigned long -> unsigned long */
+ if (integer_types_same_name_p (TYPE_NAME (parm),
+ TYPE_NAME (arg)))
+ return EXACT_MATCH_BADNESS;
+ else if (integer_types_same_name_p (TYPE_NAME (arg),
+ "int")
+ && integer_types_same_name_p (TYPE_NAME (parm),
+ "long"))
+ /* unsigned int -> unsigned long */
+ return INTEGER_PROMOTION_BADNESS;
+ else
+ /* unsigned long -> unsigned int */
+ return INTEGER_CONVERSION_BADNESS;
+ }
+ else
+ {
+ if (integer_types_same_name_p (TYPE_NAME (arg),
+ "long")
+ && integer_types_same_name_p (TYPE_NAME (parm),
+ "int"))
+ /* signed long -> unsigned int */
+ return INTEGER_CONVERSION_BADNESS;
+ else
+ /* signed int/long -> unsigned int/long */
+ return INTEGER_CONVERSION_BADNESS;
+ }
+ }
+ else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
+ {
+ if (integer_types_same_name_p (TYPE_NAME (parm),
+ TYPE_NAME (arg)))
+ return EXACT_MATCH_BADNESS;
+ 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_CONVERSION_BADNESS;
+ }
+ else
+ return INTEGER_CONVERSION_BADNESS;
+ }
+ else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
+ return INTEGER_PROMOTION_BADNESS;
+ else
+ return INTEGER_CONVERSION_BADNESS;
+ case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_RANGE:
+ case TYPE_CODE_BOOL:
+ if (TYPE_DECLARED_CLASS (arg))
+ return INCOMPATIBLE_TYPE_BADNESS;
+ return INTEGER_PROMOTION_BADNESS;
+ case TYPE_CODE_FLT:
+ return INT_FLOAT_CONVERSION_BADNESS;
+ case TYPE_CODE_PTR:
+ return NS_POINTER_CONVERSION_BADNESS;
+ default:
+ return INCOMPATIBLE_TYPE_BADNESS;
+ }
+}
+
/* 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
@@ -4008,89 +4097,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
case TYPE_CODE_FUNC:
return rank_one_type_parm_func (parm, arg, value);
case TYPE_CODE_INT:
- switch (TYPE_CODE (arg))
- {
- case TYPE_CODE_INT:
- if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
- {
- /* Deal with signed, unsigned, and plain chars and
- signed and unsigned ints. */
- if (TYPE_NOSIGN (parm))
- {
- /* This case only for character types. */
- if (TYPE_NOSIGN (arg))
- return EXACT_MATCH_BADNESS; /* plain char -> plain char */
- else /* signed/unsigned char -> plain char */
- return INTEGER_CONVERSION_BADNESS;
- }
- else if (TYPE_UNSIGNED (parm))
- {
- if (TYPE_UNSIGNED (arg))
- {
- /* unsigned int -> unsigned int, or
- unsigned long -> unsigned long */
- if (integer_types_same_name_p (TYPE_NAME (parm),
- TYPE_NAME (arg)))
- return EXACT_MATCH_BADNESS;
- else if (integer_types_same_name_p (TYPE_NAME (arg),
- "int")
- && integer_types_same_name_p (TYPE_NAME (parm),
- "long"))
- /* unsigned int -> unsigned long */
- return INTEGER_PROMOTION_BADNESS;
- else
- /* unsigned long -> unsigned int */
- return INTEGER_CONVERSION_BADNESS;
- }
- else
- {
- if (integer_types_same_name_p (TYPE_NAME (arg),
- "long")
- && integer_types_same_name_p (TYPE_NAME (parm),
- "int"))
- /* signed long -> unsigned int */
- return INTEGER_CONVERSION_BADNESS;
- else
- /* signed int/long -> unsigned int/long */
- return INTEGER_CONVERSION_BADNESS;
- }
- }
- else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
- {
- if (integer_types_same_name_p (TYPE_NAME (parm),
- TYPE_NAME (arg)))
- return EXACT_MATCH_BADNESS;
- 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_CONVERSION_BADNESS;
- }
- else
- return INTEGER_CONVERSION_BADNESS;
- }
- else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
- return INTEGER_PROMOTION_BADNESS;
- else
- return INTEGER_CONVERSION_BADNESS;
- case TYPE_CODE_ENUM:
- case TYPE_CODE_FLAGS:
- case TYPE_CODE_CHAR:
- case TYPE_CODE_RANGE:
- case TYPE_CODE_BOOL:
- if (TYPE_DECLARED_CLASS (arg))
- return INCOMPATIBLE_TYPE_BADNESS;
- return INTEGER_PROMOTION_BADNESS;
- case TYPE_CODE_FLT:
- return INT_FLOAT_CONVERSION_BADNESS;
- case TYPE_CODE_PTR:
- return NS_POINTER_CONVERSION_BADNESS;
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
- break;
+ return rank_one_type_parm_int (parm, arg, value);
case TYPE_CODE_ENUM:
switch (TYPE_CODE (arg))
{
--
2.21.0