+2019-03-06 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * f-exp.y (struct f77_boolean_val): Add comments.
+ (boolean_values): Remove uppercase versions, and end marker.
+ (yylex): Use ARRAY_SIZE for iterating over boolean_values array,
+ and use strncasecmp to achieve case insensitivity. Additionally,
+ perform whitespace cleanup around this code.
+
2019-03-06 Tom Tromey <tromey@adacore.com>
* remote-sim.c (gdbsim_target_open): Use result of
{ NULL, 0, BINOP_END }
};
-struct f77_boolean_val
+/* Holds the Fortran representation of a boolean, and the integer value we
+ substitute in when one of the matching strings is parsed. */
+struct f77_boolean_val
{
+ /* The string representing a Fortran boolean. */
const char *name;
+
+ /* The integer value to replace it with. */
int value;
-};
+};
-static const struct f77_boolean_val boolean_values[] =
+/* The set of Fortran booleans. These are matched case insensitively. */
+static const struct f77_boolean_val boolean_values[] =
{
{ ".true.", 1 },
- { ".TRUE.", 1 },
- { ".false.", 0 },
- { ".FALSE.", 0 },
- { NULL, 0 }
+ { ".false.", 0 }
};
static const struct token f77_keywords[] =
prev_lexptr = lexptr;
tokstart = lexptr;
-
- /* First of all, let us make sure we are not dealing with the
+
+ /* First of all, let us make sure we are not dealing with the
special tokens .true. and .false. which evaluate to 1 and 0. */
-
+
if (*lexptr == '.')
- {
- for (int i = 0; boolean_values[i].name != NULL; i++)
+ {
+ for (int i = 0; i < ARRAY_SIZE (boolean_values); i++)
{
- if (strncmp (tokstart, boolean_values[i].name,
- strlen (boolean_values[i].name)) == 0)
+ if (strncasecmp (tokstart, boolean_values[i].name,
+ strlen (boolean_values[i].name)) == 0)
{
- lexptr += strlen (boolean_values[i].name);
- yylval.lval = boolean_values[i].value;
+ lexptr += strlen (boolean_values[i].name);
+ yylval.lval = boolean_values[i].value;
return BOOLEAN_LITERAL;
}
}
+2019-03-06 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.fortran/types.exp (test_logical_literal_types_accepted):
+ Check upper and lower case logical literals.
+
2019-03-06 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/types.exp (test_float_literal_types_accepted):
proc test_logical_literal_types_accepted {} {
global gdb_prompt
- # Test the only possible values for a logical, TRUE and FALSE.
+ # Test the only possible values for a logical, TRUE and FALSE (and
+ # also true and false).
gdb_test "pt .TRUE." "type = logical\\*2"
gdb_test "pt .FALSE." "type = logical\\*2"
+ gdb_test "pt .true." "type = logical\\*2"
+ gdb_test "pt .false." "type = logical\\*2"
}
proc test_float_literal_types_accepted {} {