From a252e71520d278556602ac1ef01c51c6f53d5d3d Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 10 Jul 1992 23:30:40 +0000 Subject: [PATCH] * gdbtypes.c, gdbtypes.h: New function lookup_signed_typename. * c-exp.y: Call lookup_signed_typename() after seeing "signed". This handles "signed char" correctly. * c-exp.y: Recognize (but ignore) 'const' and 'volatile' keywords before a type specifier. --- gdb/ChangeLog | 8 ++++++++ gdb/c-exp.y | 11 +++++++++-- gdb/gdbtypes.c | 16 ++++++++++++++++ gdb/gdbtypes.h | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c7c91a5e7e4..9f2b62c71ab 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +Fri Jul 10 13:58:34 1992 Per Bothner (bothner@rtl.cygnus.com) + + * gdbtypes.c, gdbtypes.h: New function lookup_signed_typename. + * c-exp.y: Call lookup_signed_typename() after seeing + "signed". This handles "signed char" correctly. + * c-exp.y: Recognize (but ignore) 'const' and 'volatile' + keywords before a type specifier. + Fri Jul 10 10:19:52 1992 Fred Fish (fnf@cygnus.com) * command.c (lookup_cmd_1): Clarify descriptive comments. diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 793b7694289..fa8ebb90b99 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -161,7 +161,7 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *)); /* Special type cases, put in to allow the parser to distinguish different legal basetypes. */ -%token SIGNED_KEYWORD LONG SHORT INT_KEYWORD +%token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD %token LAST REGNAME @@ -834,6 +834,9 @@ type : ptype { $$ = lookup_member_type (lookup_function_type ($1), $3); free ((PTR)$8); } + /* "const" and "volatile" are curently ignored. */ + | CONST_KEYWORD type { $$ = $2; } + | VOLATILE_KEYWORD type { $$ = $2; } ; typebase @@ -878,7 +881,7 @@ typebase | UNSIGNED { $$ = builtin_type_unsigned_int; } | SIGNED_KEYWORD typename - { $$ = $2.type; } + { $$ = lookup_signed_typename (TYPE_NAME($2.type)); } | SIGNED_KEYWORD { $$ = builtin_type_int; } | TEMPLATE name '<' type '>' @@ -1359,6 +1362,8 @@ yylex () if (current_language->la_language == language_cplus && !strncmp (tokstart, "template", 8)) return TEMPLATE; + if (!strncmp (tokstart, "volatile", 8)) + return VOLATILE_KEYWORD; break; case 6: if (!strncmp (tokstart, "struct", 6)) @@ -1376,6 +1381,8 @@ yylex () return UNION; if (!strncmp (tokstart, "short", 5)) return SHORT; + if (!strncmp (tokstart, "const", 5)) + return CONST_KEYWORD; break; case 4: if (!strncmp (tokstart, "enum", 4)) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7559ed2d244..f34dfcb0fad 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -499,6 +499,22 @@ lookup_unsigned_typename (name) return (lookup_typename (uns, (struct block *) NULL, 0)); } +struct type * +lookup_signed_typename (name) + char *name; +{ + struct type *t; + char *uns = alloca (strlen (name) + 8); + + strcpy (uns, "signed "); + strcpy (uns + 7, name); + t = lookup_typename (uns, (struct block *) NULL, 1); + /* If we don't find "signed FOO" just try again with plain "FOO". */ + if (t != NULL) + return t; + return lookup_typename (name, (struct block *) NULL, 0); +} + /* Lookup a structure type named "struct NAME", visible in lexical block BLOCK. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 7a16b37161f..cbc329e5bc5 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -543,6 +543,9 @@ create_array_type PARAMS ((struct type *, int)); extern struct type * lookup_unsigned_typename PARAMS ((char *)); +extern struct type * +lookup_signed_typename PARAMS ((char *)); + extern void check_stub_type PARAMS ((struct type *)); -- 2.30.2