/* Special type cases, put in to allow the parser to distinguish different
legal basetypes. */
-%token INT_KEYWORD INT_S2_KEYWORD LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD
+%token INT_S1_KEYWORD INT_S2_KEYWORD INT_KEYWORD INT_S4_KEYWORD INT_S8_KEYWORD
+%token LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD LOGICAL_KEYWORD LOGICAL_S4_KEYWORD
%token LOGICAL_S8_KEYWORD
-%token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
-%token COMPLEX_KEYWORD
-%token COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD
+%token REAL_KEYWORD REAL_S4_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
+%token COMPLEX_KEYWORD COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD
+%token COMPLEX_S16_KEYWORD
%token BOOL_AND BOOL_OR BOOL_NOT
%token SINGLE DOUBLE PRECISION
%token <lval> CHARACTER
typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: TYPENAME
{ $$ = $1.type; }
+ | INT_S1_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s1; }
+ | INT_S2_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s2; }
| INT_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_integer; }
- | INT_S2_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_integer_s2; }
+ | INT_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer; }
+ | INT_S8_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_integer_s8; }
| CHARACTER
{ $$ = parse_f_type (pstate)->builtin_character; }
- | LOGICAL_S8_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical_s8; }
- | LOGICAL_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical; }
- | LOGICAL_S2_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_logical_s2; }
| LOGICAL_S1_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_logical_s1; }
+ | LOGICAL_S2_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical_s2; }
+ | LOGICAL_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical; }
+ | LOGICAL_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical; }
+ | LOGICAL_S8_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_logical_s8; }
| REAL_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real; }
+ | REAL_S4_KEYWORD
+ { $$ = parse_f_type (pstate)->builtin_real; }
| REAL_S8_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real_s8; }
| REAL_S16_KEYWORD
static const struct token f77_keywords[] =
{
/* Historically these have always been lowercase only in GDB. */
+ { "character", CHARACTER, OP_NULL, true },
{ "complex", COMPLEX_KEYWORD, OP_NULL, true },
{ "complex_4", COMPLEX_S4_KEYWORD, OP_NULL, true },
{ "complex_8", COMPLEX_S8_KEYWORD, OP_NULL, true },
{ "complex_16", COMPLEX_S16_KEYWORD, OP_NULL, true },
- { "character", CHARACTER, OP_NULL, true },
+ { "integer_1", INT_S1_KEYWORD, OP_NULL, true },
{ "integer_2", INT_S2_KEYWORD, OP_NULL, true },
+ { "integer_4", INT_S4_KEYWORD, OP_NULL, true },
+ { "integer", INT_KEYWORD, OP_NULL, true },
+ { "integer_8", INT_S8_KEYWORD, OP_NULL, true },
{ "logical_1", LOGICAL_S1_KEYWORD, OP_NULL, true },
{ "logical_2", LOGICAL_S2_KEYWORD, OP_NULL, true },
- { "logical_8", LOGICAL_S8_KEYWORD, OP_NULL, true },
- { "integer", INT_KEYWORD, OP_NULL, true },
{ "logical", LOGICAL_KEYWORD, OP_NULL, true },
+ { "logical_4", LOGICAL_S4_KEYWORD, OP_NULL, true },
+ { "logical_8", LOGICAL_S8_KEYWORD, OP_NULL, true },
+ { "real", REAL_KEYWORD, OP_NULL, true },
+ { "real_4", REAL_S4_KEYWORD, OP_NULL, true },
+ { "real_8", REAL_S8_KEYWORD, OP_NULL, true },
{ "real_16", REAL_S16_KEYWORD, OP_NULL, true },
{ "sizeof", SIZEOF, OP_NULL, true },
- { "real_8", REAL_S8_KEYWORD, OP_NULL, true },
- { "real", REAL_KEYWORD, OP_NULL, true },
{ "single", SINGLE, OP_NULL, true },
{ "double", DOUBLE, OP_NULL, true },
{ "precision", PRECISION, OP_NULL, true },
builtin_f_type->builtin_logical_s1
= arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1");
- builtin_f_type->builtin_integer_s1
- = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "integer*1");
-
- builtin_f_type->builtin_integer_s2
- = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0, "integer*2");
-
- builtin_f_type->builtin_integer_s8
- = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), 0,
- "integer*8");
-
builtin_f_type->builtin_logical_s2
= arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1, "logical*2");
+ builtin_f_type->builtin_logical
+ = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "logical*4");
+
builtin_f_type->builtin_logical_s8
= arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1,
"logical*8");
+ builtin_f_type->builtin_integer_s1
+ = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "integer*1");
+
+ builtin_f_type->builtin_integer_s2
+ = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0, "integer*2");
+
builtin_f_type->builtin_integer
= arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "integer");
- builtin_f_type->builtin_logical
- = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "logical*4");
+ builtin_f_type->builtin_integer_s8
+ = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), 0,
+ "integer*8");
builtin_f_type->builtin_real
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
gdb_test "pt 10e20" "type = real\\*\[0-9\]+"
}
+# Test the default primitive Fortran types.
+proc test_default_types {} {
+ gdb_test "ptype integer*4" "type = integer"
+ gdb_test "ptype integer_4" "type = integer"
+
+ gdb_test "ptype logical" "type = logical*4"
+
+ gdb_test "ptype real*4" "type = real"
+ gdb_test "ptype real_4" "type = real"
+
+ gdb_test "ptype complex" "type = complex*4"
+}
+
# Test the the primitive Fortran types, those that GDB should always
# know, even if the program does not define them, are in fact, known.
proc test_primitive_types_known {} {
- foreach type {void character logical*1 integer*1 integer*2 integer*8 \
- logical*2 logical*8 integer logical*4 real \
- real*8 real*16 complex*4 complex*8 complex*16} {
- gdb_test "ptype $type" [string_to_regexp "type = $type"]
+ foreach type {void character \
+ integer*1 integer*2 integer integer*8 \
+ integer_1 integer_2 integer_8 \
+ logical*1 logical*2 logical*4 logical*8 \
+ logical_1 logical_2 logical_4 logical_8 \
+ real real*8 real*16 real_8 real_16 \
+ complex*4 complex*8 complex*16 \
+ complex_4 complex_8 complex_16} {
+
+ # While TYPE_KIND is allowed as input, GDB will always return the
+ # Fortran notation TYPE*KIND
+ regsub -all "_" $type "\*" type_res
+ gdb_test "ptype $type" [string_to_regexp "type = $type_res"]
}
}
if [set_lang_fortran] then {
test_primitive_types_known
+ test_default_types
test_integer_literal_types_accepted
test_integer_literal_types_rejected
test_logical_literal_types_accepted