diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2019-03-08 10:15:08 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2019-03-09 08:09:38 -0500 |
commit | 34910087ebf8fb3f1646d9177d7c961a1b3231da (patch) | |
tree | c17d4416c87d39d076c4e1c50206347a7a046ab2 | |
parent | f1f832d6cd39e14e9f8c0ba142d2e442792119e4 (diff) | |
download | gdb-34910087ebf8fb3f1646d9177d7c961a1b3231da.zip gdb-34910087ebf8fb3f1646d9177d7c961a1b3231da.tar.gz gdb-34910087ebf8fb3f1646d9177d7c961a1b3231da.tar.bz2 |
Split rank_one_type_parm_int from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_int): New function extracted
from...
(rank_one_type): ... this.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 173 |
2 files changed, 96 insertions, 83 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 78be7d3..4ed24fa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2019-03-08 Simon Marchi <simon.marchi@efficios.com> + * gdbtypes.c (rank_one_type_parm_int): New function extracted + from... + (rank_one_type): ... this. + +2019-03-08 Simon Marchi <simon.marchi@efficios.com> + * gdbtypes.c (rank_one_type_parm_func): New function extracted from... (rank_one_type): ... this. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9cf18a6..efef999 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3887,6 +3887,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 @@ -3983,89 +4072,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)) { |