aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-10-18 01:10:25 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-10-18 01:10:25 +0000
commitf843c95fc3d55bb449ed9e681848808c9f637ee4 (patch)
tree139637eb69a38c92edc87506e010d755776dfd55 /gdb/parse.c
parentcf4d863151f03057f70f5dacba3a56b5f10e97cc (diff)
downloadgdb-f843c95fc3d55bb449ed9e681848808c9f637ee4.zip
gdb-f843c95fc3d55bb449ed9e681848808c9f637ee4.tar.gz
gdb-f843c95fc3d55bb449ed9e681848808c9f637ee4.tar.bz2
* parse.c, parser-defs.h (follow_types): New function.
* c-exp.y (ptype : typebase abs_decl): Use it. * c-exp.y (ptype): Add support for type qualifiers after the typebase. The typebase rule already has support for them before the typebase. * Makefile.in: Change the expected number of shift/reduce conflicts to 6. This is OK--the 2 new conflicts are basically the same as one of the old ones.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 94e467e..08f2b7e 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -726,6 +726,9 @@ parse_expression (string)
error ("Junk after end of expression.");
return exp;
}
+
+/* Stuff for maintaining a stack of types. Currently just used by C, but
+ probably useful for any language which declares its types "backwards". */
void
push_type (tp)
@@ -770,6 +773,50 @@ pop_type_int ()
return 0;
}
+/* Pop the type stack and return the type which corresponds to FOLLOW_TYPE
+ as modified by all the stuff on the stack. */
+struct type *
+follow_types (follow_type)
+ struct type *follow_type;
+{
+ int done = 0;
+ int array_size;
+ struct type *range_type;
+
+ while (!done)
+ switch (pop_type ())
+ {
+ case tp_end:
+ done = 1;
+ break;
+ case tp_pointer:
+ follow_type = lookup_pointer_type (follow_type);
+ break;
+ case tp_reference:
+ follow_type = lookup_reference_type (follow_type);
+ break;
+ case tp_array:
+ array_size = pop_type_int ();
+ if (array_size != -1)
+ {
+ range_type =
+ create_range_type ((struct type *) NULL,
+ builtin_type_int, 0,
+ array_size - 1);
+ follow_type =
+ create_array_type ((struct type *) NULL,
+ follow_type, range_type);
+ }
+ else
+ follow_type = lookup_pointer_type (follow_type);
+ break;
+ case tp_function:
+ follow_type = lookup_function_type (follow_type);
+ break;
+ }
+ return follow_type;
+}
+
void
_initialize_parse ()
{