Treat Character as a discrete type in Ada

A user noticed that gdb would assert when printing a certain array
with array-indexes enabled.  This turned out to be caused by the array
having an index type of Character, which is completely valid in Ada.
This patch changes the Ada support to recognize Character as a
discrete type, and adds some tests.

Because this is Ada-specific and was also reviewed internally, I am
checking it in.
This commit is contained in:
Tom Tromey
2022-09-26 08:24:14 -06:00
parent be5f79aa39
commit 98847c1e38
3 changed files with 69 additions and 1 deletions

View File

@ -4149,7 +4149,9 @@ scalar_type_p (struct type *type)
}
}
/* True iff TYPE is discrete (INT, RANGE, ENUM). */
/* True iff TYPE is discrete, as defined in the Ada Reference Manual.
This essentially means one of (INT, RANGE, ENUM) -- but note that
"enum" includes character and boolean as well. */
static int
discrete_type_p (struct type *type)
@ -4164,6 +4166,7 @@ discrete_type_p (struct type *type)
case TYPE_CODE_RANGE:
case TYPE_CODE_ENUM:
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
return 1;
default:
return 0;