* c-exp.y (%union) <type_stack>: New field.
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 7afce770e20861f8c85b8253305df6ce6ae21ebc..5ea57041d815c7f29509d37576c463282c959ee2 100644 (file)
@@ -157,6 +157,8 @@ void yyerror (char *);
     struct stoken_vector svec;
     struct type **tvec;
     int *ivec;
+
+    struct type_stack *type_stack;
   }
 
 %{
@@ -172,11 +174,12 @@ static struct stoken operator_stoken (const char *);
 /* %type <bval> block */
 
 /* Fancy type parsing.  */
-%type <voidval> func_mod direct_abs_decl abs_decl ptr_operator
 %type <tval> ptype
 %type <lval> array_mod
 %type <tval> conversion_type_id
 
+%type <type_stack> ptr_operator_ts abs_decl direct_abs_decl
+
 %token <typed_val_int> INT
 %token <typed_val_float> FLOAT
 %token <typed_val_decfloat> DECFLOAT
@@ -955,19 +958,27 @@ ptr_operator:
                ptr_operator '*'
                        { insert_type (tp_pointer); }
                const_or_volatile_or_space_identifier
-                       { $$ = 0; }
        |       '*' 
                        { insert_type (tp_pointer); }
                const_or_volatile_or_space_identifier
-                       { $$ = 0; }
        |       '&'
-                       { insert_type (tp_reference); $$ = 0; }
+                       { insert_type (tp_reference); }
        |       '&' ptr_operator
-                       { insert_type (tp_reference); $$ = 0; }
+                       { insert_type (tp_reference); }
        ;
 
-abs_decl:      ptr_operator direct_abs_decl
-       |       ptr_operator
+ptr_operator_ts: ptr_operator
+                       {
+                         $$ = get_type_stack ();
+                         /* This cleanup is eventually run by
+                            c_parse.  */
+                         make_cleanup (type_stack_cleanup, $$);
+                       }
+       ;
+
+abs_decl:      ptr_operator_ts direct_abs_decl
+                       { $$ = append_type_stack ($2, $1); }
+       |       ptr_operator_ts 
        |       direct_abs_decl
        ;
 
@@ -975,20 +986,29 @@ direct_abs_decl: '(' abs_decl ')'
                        { $$ = $2; }
        |       direct_abs_decl array_mod
                        {
+                         push_type_stack ($1);
                          push_type_int ($2);
                          push_type (tp_array);
+                         $$ = get_type_stack ();
                        }
        |       array_mod
                        {
                          push_type_int ($1);
                          push_type (tp_array);
-                         $$ = 0;
+                         $$ = get_type_stack ();
                        }
 
        |       direct_abs_decl func_mod
-                       { push_type (tp_function); }
+                       {
+                         push_type_stack ($1);
+                         push_type (tp_function);
+                         $$ = get_type_stack ();
+                       }
        |       func_mod
-                       { push_type (tp_function); }
+                       {
+                         push_type (tp_function);
+                         $$ = get_type_stack ();
+                       }
        ;
 
 array_mod:     '[' ']'
@@ -998,9 +1018,8 @@ array_mod: '[' ']'
        ;
 
 func_mod:      '(' ')'
-                       { $$ = 0; }
        |       '(' nonempty_typelist ')'
-                       { free ($2); $$ = 0; }
+                       { free ($2); }
        ;
 
 /* We used to try to recognize pointer to member types here, but
@@ -1212,7 +1231,10 @@ nonempty_typelist
 
 ptype  :       typebase
        |       ptype abs_decl
-               { $$ = follow_types ($1); }
+               {
+                 push_type_stack ($2);
+                 $$ = follow_types ($1);
+               }
        ;
 
 conversion_type_id: typebase conversion_declarator
This page took 0.027389 seconds and 4 git commands to generate.