From 3e79cecf024acb3f5739ec19d6ebd331f08e80e8 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 11 Sep 2008 14:09:37 +0000 Subject: [PATCH] * expression.h (struct expression): New member GDBARCH. * parse.c (parse_exp_in_context): Initialize it. * parser-def.h (parse_gdbarch, parse_language): New macros. * ada-exp.y (parse_type): New macro. Replace builtin_type_ macros by using parse_type. Replace current_language by parse_language. * ada-lex.l (processInt): Replace current_gdbarch by parse_gdbarch. Replace builtin_type_ macros. * c-exp.y (parse_type): New macro. Replace builtin_type_ macros by using parse_type. (parse_number): Replace current_gdbarch by parse_gdbarch. (yylex): Replace current_language by parse_language. * f-exp.y (parse_type, parse_f_type): New macros. Replace builtin_type_ macros by using parse_{f_,}type. (parse_number): Replace current_gdbarch by parse_gdbarch. (yylex): Replace current_language by parse_language. * jv-exp.y (parse_type): New macro. (parse_number): Replace builtin_type_ macros by using parse_type. * m2-exp.y (parse_type, parse_m2_type): New macros. Replace builtin_type_ macros by using parse_{m2_,}type. * objc-exp.y (parse_type): New macro. Replace builtin_type_ macros by using parse_type. (parse_number): Replace current_gdbarch by parse_gdbarch. (yylex): Replace current_language by parse_language. * p-exp.y (parse_type): New macro. Replace builtin_type_ macros by using parse_type. (parse_number): Replace current_gdbarch by parse_gdbarch. (yylex): Replace current_language by parse_language. --- gdb/ChangeLog | 38 ++++++++++++++ gdb/ada-exp.y | 30 ++++++----- gdb/ada-lex.l | 13 ++--- gdb/c-exp.y | 128 +++++++++++++++++++++++----------------------- gdb/expression.h | 1 + gdb/f-exp.y | 59 +++++++++++---------- gdb/jv-exp.y | 6 ++- gdb/m2-exp.y | 17 +++--- gdb/objc-exp.y | 90 ++++++++++++++++---------------- gdb/p-exp.y | 64 ++++++++++++----------- gdb/parse.c | 1 + gdb/parser-defs.h | 3 ++ 12 files changed, 255 insertions(+), 195 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d427f529f40..dc34aa0af3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,41 @@ +2008-09-11 Ulrich Weigand + + * expression.h (struct expression): New member GDBARCH. + * parse.c (parse_exp_in_context): Initialize it. + * parser-def.h (parse_gdbarch, parse_language): New macros. + + * ada-exp.y (parse_type): New macro. + Replace builtin_type_ macros by using parse_type. + Replace current_language by parse_language. + * ada-lex.l (processInt): Replace current_gdbarch by parse_gdbarch. + Replace builtin_type_ macros. + + * c-exp.y (parse_type): New macro. + Replace builtin_type_ macros by using parse_type. + (parse_number): Replace current_gdbarch by parse_gdbarch. + (yylex): Replace current_language by parse_language. + + * f-exp.y (parse_type, parse_f_type): New macros. + Replace builtin_type_ macros by using parse_{f_,}type. + (parse_number): Replace current_gdbarch by parse_gdbarch. + (yylex): Replace current_language by parse_language. + + * jv-exp.y (parse_type): New macro. + (parse_number): Replace builtin_type_ macros by using parse_type. + + * m2-exp.y (parse_type, parse_m2_type): New macros. + Replace builtin_type_ macros by using parse_{m2_,}type. + + * objc-exp.y (parse_type): New macro. + Replace builtin_type_ macros by using parse_type. + (parse_number): Replace current_gdbarch by parse_gdbarch. + (yylex): Replace current_language by parse_language. + + * p-exp.y (parse_type): New macro. + Replace builtin_type_ macros by using parse_type. + (parse_number): Replace current_gdbarch by parse_gdbarch. + (yylex): Replace current_language by parse_language. + 2008-09-11 Ulrich Weigand * parser-defs.h (write_exp_msymbol): Remove TEXT_SYMBOL_TYPE diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index e44cc683bcc..e4406635e31 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -52,6 +52,8 @@ Boston, MA 02110-1301, USA. */ #include "frame.h" #include "block.h" +#define parse_type builtin_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. These are only the variables @@ -571,7 +573,7 @@ opt_type_prefix : type_prefix | /* EMPTY */ { write_exp_elt_opcode (OP_TYPE); - write_exp_elt_type (builtin_type_void); + write_exp_elt_type (parse_type->builtin_void); write_exp_elt_opcode (OP_TYPE); } ; @@ -1081,8 +1083,8 @@ static struct type* find_primitive_type (char *name) { struct type *type; - type = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, + type = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, name); if (type == NULL && strcmp ("system__address", name) == 0) type = type_system_address (); @@ -1463,59 +1465,59 @@ convert_char_literal (struct type *type, LONGEST val) static struct type * type_int (void) { - return builtin_type_int; + return parse_type->builtin_int; } static struct type * type_long (void) { - return builtin_type_long; + return parse_type->builtin_long; } static struct type * type_long_long (void) { - return builtin_type_long_long; + return parse_type->builtin_long_long; } static struct type * type_float (void) { - return builtin_type_float; + return parse_type->builtin_float; } static struct type * type_double (void) { - return builtin_type_double; + return parse_type->builtin_double; } static struct type * type_long_double (void) { - return builtin_type_long_double; + return parse_type->builtin_long_double; } static struct type * type_char (void) { - return language_string_char_type (current_language, current_gdbarch); + return language_string_char_type (parse_language, parse_gdbarch); } static struct type * type_boolean (void) { - return builtin_type_bool; + return parse_type->builtin_bool; } static struct type * type_system_address (void) { struct type *type - = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, + = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, "system__address"); - return type != NULL ? type : lookup_pointer_type (builtin_type_void); + return type != NULL ? type : parse_type->builtin_data_ptr; } void diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index e4713a23d22..544313077a3 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -351,11 +351,11 @@ processInt (const char *base0, const char *num0, const char *exp0) exp -= 1; } - if ((result >> (gdbarch_int_bit (current_gdbarch)-1)) == 0) + if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_int (); - else if ((result >> (gdbarch_long_bit (current_gdbarch)-1)) == 0) + else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_long (); - else if (((result >> (gdbarch_long_bit (current_gdbarch)-1)) >> 1) == 0) + else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0) { /* We have a number representable as an unsigned integer quantity. For consistency with the C treatment, we will treat it as an @@ -364,7 +364,8 @@ processInt (const char *base0, const char *num0, const char *exp0) for the mess, but C doesn't officially guarantee that a simple assignment does the trick (no, it doesn't; read the reference manual). */ - yylval.typed_val.type = builtin_type_unsigned_long; + yylval.typed_val.type + = builtin_type (parse_gdbarch)->builtin_unsigned_long; if (result & LONGEST_SIGN) yylval.typed_val.val = (LONGEST) (result & ~LONGEST_SIGN) @@ -386,10 +387,10 @@ processReal (const char *num0) sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval); yylval.typed_val_float.type = type_float (); - if (sizeof(DOUBLEST) >= gdbarch_double_bit (current_gdbarch) + if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch) / TARGET_CHAR_BIT) yylval.typed_val_float.type = type_double (); - if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (current_gdbarch) + if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch) / TARGET_CHAR_BIT) yylval.typed_val_float.type = type_long_double (); diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 7ebefcbd9df..6d169405840 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -55,6 +55,8 @@ Boston, MA 02110-1301, USA. */ #include "cp-support.h" #include "dfp.h" +#define parse_type builtin_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only the variables @@ -554,7 +556,7 @@ exp : VARIABLE exp : SIZEOF '(' type ')' %prec UNARY { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int); + write_exp_elt_type (parse_type->builtin_int); CHECK_TYPEDEF ($3); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_opcode (OP_LONG); } @@ -570,12 +572,12 @@ exp : STRING while (count-- > 0) { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_ARRAY); @@ -587,14 +589,14 @@ exp : STRING /* C++. */ exp : TRUEKEYWORD { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool); + write_exp_elt_type (parse_type->builtin_bool); write_exp_elt_longcst ((LONGEST) 1); write_exp_elt_opcode (OP_LONG); } ; exp : FALSEKEYWORD { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool); + write_exp_elt_type (parse_type->builtin_bool); write_exp_elt_longcst ((LONGEST) 0); write_exp_elt_opcode (OP_LONG); } ; @@ -841,61 +843,61 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ : TYPENAME { $$ = $1.type; } | INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_int; } + { $$ = parse_type->builtin_int; } | LONG - { $$ = builtin_type (current_gdbarch)->builtin_long; } + { $$ = parse_type->builtin_long; } | SHORT - { $$ = builtin_type (current_gdbarch)->builtin_short; } + { $$ = parse_type->builtin_short; } | LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long; } + { $$ = parse_type->builtin_long; } | LONG SIGNED_KEYWORD INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long; } + { $$ = parse_type->builtin_long; } | LONG SIGNED_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long; } + { $$ = parse_type->builtin_long; } | SIGNED_KEYWORD LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long; } + { $$ = parse_type->builtin_long; } | UNSIGNED LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } + { $$ = parse_type->builtin_unsigned_long; } | LONG UNSIGNED INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } + { $$ = parse_type->builtin_unsigned_long; } | LONG UNSIGNED - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } + { $$ = parse_type->builtin_unsigned_long; } | LONG LONG - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | LONG LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | LONG LONG SIGNED_KEYWORD INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | LONG LONG SIGNED_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | SIGNED_KEYWORD LONG LONG - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | SIGNED_KEYWORD LONG LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long_long; } + { $$ = parse_type->builtin_long_long; } | UNSIGNED LONG LONG - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | UNSIGNED LONG LONG INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | LONG LONG UNSIGNED - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | LONG LONG UNSIGNED INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | SHORT INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_short; } + { $$ = parse_type->builtin_short; } | SHORT SIGNED_KEYWORD INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_short; } + { $$ = parse_type->builtin_short; } | SHORT SIGNED_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_short; } + { $$ = parse_type->builtin_short; } | UNSIGNED SHORT INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } + { $$ = parse_type->builtin_unsigned_short; } | SHORT UNSIGNED - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } + { $$ = parse_type->builtin_unsigned_short; } | SHORT UNSIGNED INT_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } + { $$ = parse_type->builtin_unsigned_short; } | DOUBLE_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_double; } + { $$ = parse_type->builtin_double; } | LONG DOUBLE_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_long_double; } + { $$ = parse_type->builtin_long_double; } | STRUCT name { $$ = lookup_struct (copy_name ($2), expression_context_block); } @@ -911,11 +913,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ | UNSIGNED typename { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } | UNSIGNED - { $$ = builtin_type (current_gdbarch)->builtin_unsigned_int; } + { $$ = parse_type->builtin_unsigned_int; } | SIGNED_KEYWORD typename { $$ = lookup_signed_typename (TYPE_NAME($2.type)); } | SIGNED_KEYWORD - { $$ = builtin_type (current_gdbarch)->builtin_int; } + { $$ = parse_type->builtin_int; } /* It appears that this rule for templates is never reduced; template recognition happens by lookahead in the token processing code in yylex. */ @@ -1005,19 +1007,19 @@ typename: TYPENAME { $$.stoken.ptr = "int"; $$.stoken.length = 3; - $$.type = builtin_type (current_gdbarch)->builtin_int; + $$.type = parse_type->builtin_int; } | LONG { $$.stoken.ptr = "long"; $$.stoken.length = 4; - $$.type = builtin_type (current_gdbarch)->builtin_long; + $$.type = parse_type->builtin_long; } | SHORT { $$.stoken.ptr = "short"; $$.stoken.length = 5; - $$.type = builtin_type (current_gdbarch)->builtin_short; + $$.type = parse_type->builtin_short; } ; @@ -1120,7 +1122,7 @@ parse_number (p, len, parsed_float, putithere) { p[len - 2] = '\0'; putithere->typed_val_decfloat.type - = builtin_type (current_gdbarch)->builtin_decfloat; + = parse_type->builtin_decfloat; decimal_from_string (putithere->typed_val_decfloat.val, 4, p); p[len - 2] = 'd'; return DECFLOAT; @@ -1130,7 +1132,7 @@ parse_number (p, len, parsed_float, putithere) { p[len - 2] = '\0'; putithere->typed_val_decfloat.type - = builtin_type (current_gdbarch)->builtin_decdouble; + = parse_type->builtin_decdouble; decimal_from_string (putithere->typed_val_decfloat.val, 8, p); p[len - 2] = 'd'; return DECFLOAT; @@ -1140,7 +1142,7 @@ parse_number (p, len, parsed_float, putithere) { p[len - 2] = '\0'; putithere->typed_val_decfloat.type - = builtin_type (current_gdbarch)->builtin_declong; + = parse_type->builtin_declong; decimal_from_string (putithere->typed_val_decfloat.val, 16, p); p[len - 2] = 'd'; return DECFLOAT; @@ -1155,7 +1157,7 @@ parse_number (p, len, parsed_float, putithere) if (num == 1) putithere->typed_val_float.type = - builtin_type (current_gdbarch)->builtin_double; + parse_type->builtin_double; if (num == 2 ) { @@ -1163,10 +1165,10 @@ parse_number (p, len, parsed_float, putithere) double. */ if (!strcasecmp (s, "f")) putithere->typed_val_float.type = - builtin_type (current_gdbarch)->builtin_float; + parse_type->builtin_float; else if (!strcasecmp (s, "l")) putithere->typed_val_float.type = - builtin_type (current_gdbarch)->builtin_long_double; + parse_type->builtin_long_double; else { free (s); @@ -1277,9 +1279,9 @@ parse_number (p, len, parsed_float, putithere) un = (ULONGEST)n >> 2; if (long_p == 0 - && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); + high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1); /* A large decimal (not hex or octal) constant (between INT_MAX and UINT_MAX) is a long or unsigned long, according to ANSI, @@ -1287,28 +1289,28 @@ parse_number (p, len, parsed_float, putithere) int. This probably should be fixed. GCC gives a warning on such constants. */ - unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int; - signed_type = builtin_type (current_gdbarch)->builtin_int; + unsigned_type = parse_type->builtin_unsigned_int; + signed_type = parse_type->builtin_int; } else if (long_p <= 1 - && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); - unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long; - signed_type = builtin_type (current_gdbarch)->builtin_long; + high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1); + unsigned_type = parse_type->builtin_unsigned_long; + signed_type = parse_type->builtin_long; } else { int shift; if (sizeof (ULONGEST) * HOST_CHAR_BIT - < gdbarch_long_long_bit (current_gdbarch)) + < gdbarch_long_long_bit (parse_gdbarch)) /* A long long does not fit in a LONGEST. */ shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1); else - shift = (gdbarch_long_long_bit (current_gdbarch) - 1); + shift = (gdbarch_long_long_bit (parse_gdbarch) - 1); high_bit = (ULONGEST) 1 << shift; - unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long; - signed_type = builtin_type (current_gdbarch)->builtin_long_long; + unsigned_type = parse_type->builtin_unsigned_long_long; + signed_type = parse_type->builtin_long_long; } putithere->typed_val_int.val = n; @@ -1481,7 +1483,7 @@ yylex () } yylval.typed_val_int.val = c; - yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char; + yylval.typed_val_int.type = parse_type->builtin_char; c = *lexptr++; if (c != '\'') @@ -1733,7 +1735,7 @@ yylex () case 8: if (strncmp (tokstart, "unsigned", 8) == 0) return UNSIGNED; - if (current_language->la_language == language_cplus + if (parse_language->la_language == language_cplus && strncmp (tokstart, "template", 8) == 0) return TEMPLATE; if (strncmp (tokstart, "volatile", 8) == 0) @@ -1750,7 +1752,7 @@ yylex () return DOUBLE_KEYWORD; break; case 5: - if (current_language->la_language == language_cplus) + if (parse_language->la_language == language_cplus) { if (strncmp (tokstart, "false", 5) == 0) return FALSEKEYWORD; @@ -1769,7 +1771,7 @@ yylex () return ENUM; if (strncmp (tokstart, "long", 4) == 0) return LONG; - if (current_language->la_language == language_cplus) + if (parse_language->la_language == language_cplus) { if (strncmp (tokstart, "true", 4) == 0) return TRUEKEYWORD; @@ -1805,7 +1807,7 @@ yylex () sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, - current_language->la_language == language_cplus + parse_language->la_language == language_cplus ? &is_a_field_of_this : (int *) NULL); /* Call lookup_symtab, not lookup_partial_symtab, in case there are no psymtabs (coff, xcoff, or some future change to blow away the @@ -1838,8 +1840,8 @@ yylex () return TYPENAME; } yylval.tsym.type - = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, tmp); + = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, tmp); if (yylval.tsym.type != NULL) return TYPENAME; diff --git a/gdb/expression.h b/gdb/expression.h index 084c70effed..4590febe804 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -373,6 +373,7 @@ union exp_element struct expression { const struct language_defn *language_defn; /* language it was entered in */ + struct gdbarch *gdbarch; /* architecture it was parsed in */ int nelts; union exp_element elts[1]; }; diff --git a/gdb/f-exp.y b/gdb/f-exp.y index c50106cc7f1..1aacc378237 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -57,6 +57,9 @@ Boston, MA 02110-1301, USA. */ #include "block.h" #include +#define parse_type builtin_type (parse_gdbarch) +#define parse_f_type builtin_f_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only the variables @@ -447,7 +450,7 @@ exp : NAME_OR_INT exp : FLOAT { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_f_real_s8); + write_exp_elt_type (parse_f_type->builtin_real_s8); write_exp_elt_dblcst ($1); write_exp_elt_opcode (OP_DOUBLE); } ; @@ -460,7 +463,7 @@ exp : VARIABLE exp : SIZEOF '(' type ')' %prec UNARY { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_f_integer); + write_exp_elt_type (parse_f_type->builtin_integer); CHECK_TYPEDEF ($3); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_opcode (OP_LONG); } @@ -551,8 +554,8 @@ ptype : typebase { range_type = create_range_type ((struct type *) NULL, - builtin_type_f_integer, 0, - array_size - 1); + parse_f_type->builtin_integer, + 0, array_size - 1); follow_type = create_array_type ((struct type *) NULL, follow_type, range_type); @@ -597,29 +600,29 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ : TYPENAME { $$ = $1.type; } | INT_KEYWORD - { $$ = builtin_type_f_integer; } + { $$ = parse_f_type->builtin_integer; } | INT_S2_KEYWORD - { $$ = builtin_type_f_integer_s2; } + { $$ = parse_f_type->builtin_integer_s2; } | CHARACTER - { $$ = builtin_type_f_character; } + { $$ = parse_f_type->builtin_character; } | LOGICAL_KEYWORD - { $$ = builtin_type_f_logical;} + { $$ = parse_f_type->builtin_logical; } | LOGICAL_S2_KEYWORD - { $$ = builtin_type_f_logical_s2;} + { $$ = parse_f_type->builtin_logical_s2; } | LOGICAL_S1_KEYWORD - { $$ = builtin_type_f_logical_s1;} + { $$ = parse_f_type->builtin_logical_s1; } | REAL_KEYWORD - { $$ = builtin_type_f_real;} + { $$ = parse_f_type->builtin_real; } | REAL_S8_KEYWORD - { $$ = builtin_type_f_real_s8;} + { $$ = parse_f_type->builtin_real_s8; } | REAL_S16_KEYWORD - { $$ = builtin_type_f_real_s16;} + { $$ = parse_f_type->builtin_real_s16; } | COMPLEX_S8_KEYWORD - { $$ = builtin_type_f_complex_s8;} + { $$ = parse_f_type->builtin_complex_s8; } | COMPLEX_S16_KEYWORD - { $$ = builtin_type_f_complex_s16;} + { $$ = parse_f_type->builtin_complex_s16; } | COMPLEX_S32_KEYWORD - { $$ = builtin_type_f_complex_s32;} + { $$ = parse_f_type->builtin_complex_s32; } ; nonempty_typelist @@ -762,26 +765,26 @@ parse_number (p, len, parsed_float, putithere) target int size is different to the target long size. In the expression below, we could have tested - (n >> gdbarch_int_bit (current_gdbarch)) + (n >> gdbarch_int_bit (parse_gdbarch)) to see if it was zero, but too many compilers warn about that, when ints and longs are the same size. So we shift it twice, with fewer bits each time, for the same result. */ - if ((gdbarch_int_bit (current_gdbarch) != gdbarch_long_bit (current_gdbarch) + if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch) && ((n >> 2) - >> (gdbarch_int_bit (current_gdbarch)-2))) /* Avoid shift warning */ + >> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */ || long_p) { - high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch)-1); - unsigned_type = builtin_type_unsigned_long; - signed_type = builtin_type_long; + high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1); + unsigned_type = parse_type->builtin_unsigned_long; + signed_type = parse_type->builtin_long; } else { - high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch)-1); - unsigned_type = builtin_type_unsigned_int; - signed_type = builtin_type_int; + high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1); + unsigned_type = parse_type->builtin_unsigned_int; + signed_type = parse_type->builtin_int; } putithere->typed_val.val = n; @@ -1170,7 +1173,7 @@ yylex () sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, - current_language->la_language == language_cplus + parse_language->la_language == language_cplus ? &is_a_field_of_this : NULL); if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) { @@ -1178,8 +1181,8 @@ yylex () return TYPENAME; } yylval.tsym.type - = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, tmp); + = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, tmp); if (yylval.tsym.type != NULL) return TYPENAME; diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y index 1ec73ab0951..ff9a7a11319 100644 --- a/gdb/jv-exp.y +++ b/gdb/jv-exp.y @@ -51,6 +51,8 @@ Boston, MA 02110-1301, USA. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "block.h" +#define parse_type builtin_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only the variables @@ -723,9 +725,9 @@ parse_number (p, len, parsed_float, putithere) c = tolower (p[len - 1]); if (c == 'f' || c == 'F') - putithere->typed_val_float.type = builtin_type_float; + putithere->typed_val_float.type = parse_type->builtin_float; else if (isdigit (c) || c == '.' || c == 'd' || c == 'D') - putithere->typed_val_float.type = builtin_type_double; + putithere->typed_val_float.type = parse_type->builtin_double; else return ERROR; diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index bb1c4ea3ad2..b7b28fe8924 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -52,6 +52,9 @@ Boston, MA 02110-1301, USA. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "block.h" +#define parse_type builtin_type (parse_gdbarch) +#define parse_m2_type builtin_m2_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only the variables @@ -497,7 +500,7 @@ exp : M2_FALSE exp : INT { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_int); + write_exp_elt_type (parse_m2_type->builtin_int); write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_opcode (OP_LONG); } ; @@ -505,7 +508,7 @@ exp : INT exp : UINT { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_card); + write_exp_elt_type (parse_m2_type->builtin_card); write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_opcode (OP_LONG); } @@ -513,7 +516,7 @@ exp : UINT exp : CHAR { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_char); + write_exp_elt_type (parse_m2_type->builtin_char); write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_opcode (OP_LONG); } ; @@ -521,7 +524,7 @@ exp : CHAR exp : FLOAT { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_m2_real); + write_exp_elt_type (parse_m2_type->builtin_real); write_exp_elt_dblcst ($1); write_exp_elt_opcode (OP_DOUBLE); } ; @@ -531,7 +534,7 @@ exp : variable exp : SIZE '(' type ')' %prec UNARY { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); + write_exp_elt_type (parse_type->builtin_int); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_opcode (OP_LONG); } ; @@ -654,14 +657,14 @@ int overflow(a,b) long a,b; { - return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a; + return (MAX_OF_TYPE(parse_m2_type->builtin_int) - b) < a; } int uoverflow(a,b) unsigned long a,b; { - return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a; + return (MAX_OF_TYPE(parse_m2_type->builtin_card) - b) < a; } #endif /* FIXME */ diff --git a/gdb/objc-exp.y b/gdb/objc-exp.y index cde056c2a64..1527a049310 100644 --- a/gdb/objc-exp.y +++ b/gdb/objc-exp.y @@ -54,6 +54,8 @@ #include "completer.h" /* For skip_quoted(). */ #include "block.h" +#define parse_type builtin_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only @@ -338,7 +340,7 @@ exp : '[' TYPENAME error ("%s is not an ObjC Class", copy_name ($2.stoken)); write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); + write_exp_elt_type (parse_type->builtin_int); write_exp_elt_longcst ((LONGEST) class); write_exp_elt_opcode (OP_LONG); start_msglist(); @@ -353,7 +355,7 @@ exp : '[' TYPENAME exp : '[' CLASSNAME { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); + write_exp_elt_type (parse_type->builtin_int); write_exp_elt_longcst ((LONGEST) $2.class); write_exp_elt_opcode (OP_LONG); start_msglist(); @@ -575,7 +577,7 @@ exp : SELECTOR exp : SIZEOF '(' type ')' %prec UNARY { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); + write_exp_elt_type (parse_type->builtin_int); CHECK_TYPEDEF ($3); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_opcode (OP_LONG); } @@ -592,12 +594,12 @@ exp : STRING while (count-- > 0) { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_ARRAY); @@ -860,31 +862,31 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */ $$ = $1.type; } | INT_KEYWORD - { $$ = builtin_type_int; } + { $$ = parse_type->builtin_int; } | LONG - { $$ = builtin_type_long; } + { $$ = parse_type->builtin_long; } | SHORT - { $$ = builtin_type_short; } + { $$ = parse_type->builtin_short; } | LONG INT_KEYWORD - { $$ = builtin_type_long; } + { $$ = parse_type->builtin_long; } | UNSIGNED LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long; } + { $$ = parse_type->builtin_unsigned_long; } | LONG LONG - { $$ = builtin_type_long_long; } + { $$ = parse_type->builtin_long_long; } | LONG LONG INT_KEYWORD - { $$ = builtin_type_long_long; } + { $$ = parse_type->builtin_long_long; } | UNSIGNED LONG LONG - { $$ = builtin_type_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | UNSIGNED LONG LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long_long; } + { $$ = parse_type->builtin_unsigned_long_long; } | SHORT INT_KEYWORD - { $$ = builtin_type_short; } + { $$ = parse_type->builtin_short; } | UNSIGNED SHORT INT_KEYWORD - { $$ = builtin_type_unsigned_short; } + { $$ = parse_type->builtin_unsigned_short; } | DOUBLE_KEYWORD - { $$ = builtin_type_double; } + { $$ = parse_type->builtin_double; } | LONG DOUBLE_KEYWORD - { $$ = builtin_type_long_double; } + { $$ = parse_type->builtin_long_double; } | STRUCT name { $$ = lookup_struct (copy_name ($2), expression_context_block); } @@ -900,11 +902,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */ | UNSIGNED typename { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } | UNSIGNED - { $$ = builtin_type_unsigned_int; } + { $$ = parse_type->builtin_unsigned_int; } | SIGNED_KEYWORD typename { $$ = lookup_signed_typename (TYPE_NAME($2.type)); } | SIGNED_KEYWORD - { $$ = builtin_type_int; } + { $$ = parse_type->builtin_int; } | TEMPLATE name '<' type '>' { $$ = lookup_template_type(copy_name($2), $4, expression_context_block); @@ -921,19 +923,19 @@ typename: TYPENAME { $$.stoken.ptr = "int"; $$.stoken.length = 3; - $$.type = builtin_type_int; + $$.type = parse_type->builtin_int; } | LONG { $$.stoken.ptr = "long"; $$.stoken.length = 4; - $$.type = builtin_type_long; + $$.type = parse_type->builtin_long; } | SHORT { $$.stoken.ptr = "short"; $$.stoken.length = 5; - $$.type = builtin_type_short; + $$.type = parse_type->builtin_short; } ; @@ -1019,11 +1021,11 @@ parse_number (p, len, parsed_float, putithere) c = tolower (p[len - 1]); if (c == 'f') - putithere->typed_val_float.type = builtin_type_float; + putithere->typed_val_float.type = parse_type->builtin_float; else if (c == 'l') - putithere->typed_val_float.type = builtin_type_long_double; + putithere->typed_val_float.type = parse_type->builtin_long_double; else if (isdigit (c) || c == '.') - putithere->typed_val_float.type = builtin_type_double; + putithere->typed_val_float.type = parse_type->builtin_double; else return ERROR; @@ -1129,9 +1131,9 @@ parse_number (p, len, parsed_float, putithere) un = (unsigned LONGEST)n >> 2; if (long_p == 0 - && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); + high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1); /* A large decimal (not hex or octal) constant (between INT_MAX and UINT_MAX) is a long or unsigned long, according to ANSI, @@ -1139,28 +1141,28 @@ parse_number (p, len, parsed_float, putithere) int. This probably should be fixed. GCC gives a warning on such constants. */ - unsigned_type = builtin_type_unsigned_int; - signed_type = builtin_type_int; + unsigned_type = parse_type->builtin_unsigned_int; + signed_type = parse_type->builtin_int; } else if (long_p <= 1 - && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); - unsigned_type = builtin_type_unsigned_long; - signed_type = builtin_type_long; + high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1); + unsigned_type = parse_type->builtin_unsigned_long; + signed_type = parse_type->builtin_long; } else { high_bit = (((unsigned LONGEST)1) - << (gdbarch_long_long_bit (current_gdbarch) - 32 - 1) + << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1) << 16 << 16); if (high_bit == 0) /* A long long does not fit in a LONGEST. */ high_bit = (unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1); - unsigned_type = builtin_type_unsigned_long_long; - signed_type = builtin_type_long_long; + unsigned_type = parse_type->builtin_unsigned_long_long; + signed_type = parse_type->builtin_long_long; } putithere->typed_val_int.val = n; @@ -1276,7 +1278,7 @@ yylex () error ("Empty character constant."); yylval.typed_val_int.val = c; - yylval.typed_val_int.type = builtin_type_char; + yylval.typed_val_int.type = parse_type->builtin_char; c = *lexptr++; if (c != '\'') @@ -1562,7 +1564,7 @@ yylex () case 8: if (strncmp (tokstart, "unsigned", 8) == 0) return UNSIGNED; - if (current_language->la_language == language_cplus + if (parse_language->la_language == language_cplus && strncmp (tokstart, "template", 8) == 0) return TEMPLATE; if (strncmp (tokstart, "volatile", 8) == 0) @@ -1579,7 +1581,7 @@ yylex () return DOUBLE_KEYWORD; break; case 5: - if ((current_language->la_language == language_cplus) + if ((parse_language->la_language == language_cplus) && strncmp (tokstart, "class", 5) == 0) return CLASS; if (strncmp (tokstart, "union", 5) == 0) @@ -1623,8 +1625,8 @@ yylex () int is_a_field_of_this = 0, *need_this; int hextype; - if (current_language->la_language == language_cplus || - current_language->la_language == language_objc) + if (parse_language->la_language == language_cplus || + parse_language->la_language == language_objc) need_this = &is_a_field_of_this; else need_this = (int *) NULL; @@ -1736,8 +1738,8 @@ yylex () return TYPENAME; } yylval.tsym.type - = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, tmp); + = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, tmp); if (yylval.tsym.type != NULL) return TYPENAME; diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 0988481a7db..4b5ceb2e660 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -58,6 +58,8 @@ Boston, MA 02110-1301, USA. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "block.h" +#define parse_type builtin_type (parse_gdbarch) + /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in gdb. Note that these are only the variables @@ -381,8 +383,8 @@ exp : exp '/' { && is_integral_type (current_type)) { write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (builtin_type_long_double); - current_type = builtin_type_long_double; + write_exp_elt_type (parse_type->builtin_long_double); + current_type = parse_type->builtin_long_double; write_exp_elt_opcode (UNOP_CAST); leftdiv_is_integer = 0; } @@ -417,37 +419,37 @@ exp : exp RSH exp exp : exp '=' exp { write_exp_elt_opcode (BINOP_EQUAL); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; exp : exp NOTEQUAL exp { write_exp_elt_opcode (BINOP_NOTEQUAL); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; exp : exp LEQ exp { write_exp_elt_opcode (BINOP_LEQ); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; exp : exp GEQ exp { write_exp_elt_opcode (BINOP_GEQ); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; exp : exp '<' exp { write_exp_elt_opcode (BINOP_LESS); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; exp : exp '>' exp { write_exp_elt_opcode (BINOP_GTR); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; } ; @@ -470,14 +472,14 @@ exp : exp ASSIGN exp exp : TRUEKEYWORD { write_exp_elt_opcode (OP_BOOL); write_exp_elt_longcst ((LONGEST) $1); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; write_exp_elt_opcode (OP_BOOL); } ; exp : FALSEKEYWORD { write_exp_elt_opcode (OP_BOOL); write_exp_elt_longcst ((LONGEST) $1); - current_type = builtin_type_bool; + current_type = parse_type->builtin_bool; write_exp_elt_opcode (OP_BOOL); } ; @@ -518,7 +520,7 @@ exp : VARIABLE exp : SIZEOF '(' type ')' %prec UNARY { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); + write_exp_elt_type (parse_type->builtin_int); CHECK_TYPEDEF ($3); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_opcode (OP_LONG); } @@ -534,12 +536,12 @@ exp : STRING while (count-- > 0) { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); + write_exp_elt_type (parse_type->builtin_char); write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_ARRAY); @@ -832,11 +834,11 @@ parse_number (p, len, parsed_float, putithere) c = tolower (p[len - 1]); if (c == 'f') - putithere->typed_val_float.type = builtin_type_float; + putithere->typed_val_float.type = parse_type->builtin_float; else if (c == 'l') - putithere->typed_val_float.type = builtin_type_long_double; + putithere->typed_val_float.type = parse_type->builtin_long_double; else if (isdigit (c) || c == '.') - putithere->typed_val_float.type = builtin_type_double; + putithere->typed_val_float.type = parse_type->builtin_double; else return ERROR; @@ -942,9 +944,9 @@ parse_number (p, len, parsed_float, putithere) un = (ULONGEST)n >> 2; if (long_p == 0 - && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); + high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1); /* A large decimal (not hex or octal) constant (between INT_MAX and UINT_MAX) is a long or unsigned long, according to ANSI, @@ -952,28 +954,28 @@ parse_number (p, len, parsed_float, putithere) int. This probably should be fixed. GCC gives a warning on such constants. */ - unsigned_type = builtin_type_unsigned_int; - signed_type = builtin_type_int; + unsigned_type = parse_type->builtin_unsigned_int; + signed_type = parse_type->builtin_int; } else if (long_p <= 1 - && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) + && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0) { - high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); - unsigned_type = builtin_type_unsigned_long; - signed_type = builtin_type_long; + high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1); + unsigned_type = parse_type->builtin_unsigned_long; + signed_type = parse_type->builtin_long; } else { int shift; if (sizeof (ULONGEST) * HOST_CHAR_BIT - < gdbarch_long_long_bit (current_gdbarch)) + < gdbarch_long_long_bit (parse_gdbarch)) /* A long long does not fit in a LONGEST. */ shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1); else - shift = (gdbarch_long_long_bit (current_gdbarch) - 1); + shift = (gdbarch_long_long_bit (parse_gdbarch) - 1); high_bit = (ULONGEST) 1 << shift; - unsigned_type = builtin_type_unsigned_long_long; - signed_type = builtin_type_long_long; + unsigned_type = parse_type->builtin_unsigned_long_long; + signed_type = parse_type->builtin_long_long; } putithere->typed_val_int.val = n; @@ -1142,7 +1144,7 @@ yylex () error ("Empty character constant."); yylval.typed_val_int.val = c; - yylval.typed_val_int.type = builtin_type_char; + yylval.typed_val_int.type = parse_type->builtin_char; c = *lexptr++; if (c != '\'') @@ -1636,8 +1638,8 @@ yylex () return TYPENAME; } yylval.tsym.type - = language_lookup_primitive_type_by_name (current_language, - current_gdbarch, tmp); + = language_lookup_primitive_type_by_name (parse_language, + parse_gdbarch, tmp); if (yylval.tsym.type != NULL) { free (uptokstart); diff --git a/gdb/parse.c b/gdb/parse.c index 6b32d00a26d..e3a62c7a2f0 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1027,6 +1027,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma, expout = (struct expression *) xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size)); expout->language_defn = current_language; + expout->gdbarch = current_gdbarch; TRY_CATCH (except, RETURN_MASK_ALL) { diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 28cd02e0821..b2c5b83e83a 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -32,6 +32,9 @@ extern struct expression *expout; extern int expout_size; extern int expout_ptr; +#define parse_gdbarch (expout->gdbarch) +#define parse_language (expout->language_defn) + /* If this is nonzero, this block is used as the lexical context for symbol names. */ -- 2.30.2