diff options
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r-- | gdb/f-exp.y | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y index c0afebc..19e4c70 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1278,6 +1278,28 @@ static const struct f77_boolean_val boolean_values[] = { ".false.", 0 } }; +static const struct token f_intrinsics[] = +{ + /* The following correspond to actual functions in Fortran and are case + insensitive. */ + { "kind", KIND, OP_NULL, false }, + { "abs", UNOP_INTRINSIC, UNOP_ABS, false }, + { "mod", BINOP_INTRINSIC, BINOP_MOD, false }, + { "floor", UNOP_OR_BINOP_INTRINSIC, FORTRAN_FLOOR, false }, + { "ceiling", UNOP_OR_BINOP_INTRINSIC, FORTRAN_CEILING, false }, + { "modulo", BINOP_INTRINSIC, BINOP_FORTRAN_MODULO, false }, + { "cmplx", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_CMPLX, false }, + { "lbound", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_LBOUND, false }, + { "ubound", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_UBOUND, false }, + { "allocated", UNOP_INTRINSIC, UNOP_FORTRAN_ALLOCATED, false }, + { "associated", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ASSOCIATED, false }, + { "rank", UNOP_INTRINSIC, UNOP_FORTRAN_RANK, false }, + { "size", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_ARRAY_SIZE, false }, + { "shape", UNOP_INTRINSIC, UNOP_FORTRAN_SHAPE, false }, + { "loc", UNOP_INTRINSIC, UNOP_FORTRAN_LOC, false }, + { "sizeof", SIZEOF, OP_NULL, false }, +}; + static const token f_keywords[] = { /* Historically these have always been lowercase only in GDB. */ @@ -1300,27 +1322,9 @@ static const token f_keywords[] = { "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 }, { "single", SINGLE, OP_NULL, true }, { "double", DOUBLE, OP_NULL, true }, { "precision", PRECISION, OP_NULL, true }, - /* The following correspond to actual functions in Fortran and are case - insensitive. */ - { "kind", KIND, OP_NULL, false }, - { "abs", UNOP_INTRINSIC, UNOP_ABS, false }, - { "mod", BINOP_INTRINSIC, BINOP_MOD, false }, - { "floor", UNOP_OR_BINOP_INTRINSIC, FORTRAN_FLOOR, false }, - { "ceiling", UNOP_OR_BINOP_INTRINSIC, FORTRAN_CEILING, false }, - { "modulo", BINOP_INTRINSIC, BINOP_FORTRAN_MODULO, false }, - { "cmplx", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_CMPLX, false }, - { "lbound", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_LBOUND, false }, - { "ubound", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_UBOUND, false }, - { "allocated", UNOP_INTRINSIC, UNOP_FORTRAN_ALLOCATED, false }, - { "associated", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ASSOCIATED, false }, - { "rank", UNOP_INTRINSIC, UNOP_FORTRAN_RANK, false }, - { "size", UNOP_OR_BINOP_OR_TERNOP_INTRINSIC, FORTRAN_ARRAY_SIZE, false }, - { "shape", UNOP_INTRINSIC, UNOP_FORTRAN_SHAPE, false }, - { "loc", UNOP_INTRINSIC, UNOP_FORTRAN_LOC, false }, }; /* Implementation of a dynamically expandable buffer for processing input @@ -1663,7 +1667,22 @@ yylex (void) pstate->gdbarch (), tmp.c_str ()); if (yylval.tsym.type != NULL) return TYPENAME; - + + /* This is post the symbol search as symbols can hide intrinsics. Also, + give Fortran intrinsics priority over C symbols. This prevents + non-Fortran symbols from hiding intrinsics, for example abs. */ + if (!result.symbol || result.symbol->language () != language_fortran) + for (const auto &intrinsic : f_intrinsics) + { + gdb_assert (!intrinsic.case_sensitive); + if (strlen (intrinsic.oper) == namelen + && strncasecmp (tokstart, intrinsic.oper, namelen) == 0) + { + yylval.opcode = intrinsic.opcode; + return intrinsic.token; + } + } + /* Input names that aren't symbols but ARE valid hex numbers, when the input radix permits them, can be names or numbers depending on the parse. Note we support radixes > 16 here. */ |