This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] broken build using bison-1.75


I think I've figured out what the real problem is, here.

If you write a rule without a final action, like the start rule from
p-exp.y:

    start   :       { current_type = NULL;
                      search_field = 0;
                    }
                    normal_start;

then Bison inserts a default final action, { $$ = $1; }.  However, in
this example, that's a bad idea, since $1 refers to the mid-rule
action `{ current_type = ... }', and that has to type.  That's why the
error message says:

/home/js/MIPS/toolchain/mips-linux-gdb/gdb/../../gdb+dejagnu-5.3-branch-20021031/gdb/c-exp.y:248.5-251.3: type clash (`voidval' `') on default action

I think that's complaining that there's a clash between the type of
`start', which is `voidval', and the type of the mid-rule action,
which is being printed as `'.

Your fix changes that into:

    start   :       setup normal_start
            ;

    setup   :       { current_type = NULL;
                      search_field = 0;
                    }
            ;

And since you also add the declaration:

    %type <voidval> ... setup ...

The `start' rule's $1 is now `setup', which is declared to have type
`voidval'.

Ironically, if you don't declare a type for a rule, yacc just assumes
it doesn't return a value --- which is what's actually going on here.
So I think it would be simplest just to delete all uses of `voidval'
altogether.  (Its presence predates Red Hat's internal CVS repository,
inherited from Cygnus, which has history back to 1991.  And it's not
mentioned in any of the ChangeLogs.)

Here's a patch that does that.  The result compiles cleanly using
Bison 1.28, byacc 1.9, and Bison 1.75.  The same could be done for the
other grammars, too.

2002-11-07  Jim Blandy  <jimb@redhat.com>

	Don't give a type for rules that return no value; this is what
	yacc expects, so the error-checking works better.
	* p-exp.y (%union): Remove `voidval' member.
	(exp, exp1, type_exp, start, normal_start, variable,
	qualified_name, VARIABLE): Don't declare these to have type
	'voidval'.
	(start): No need for dummy action here.

Index: gdb/p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.17
diff -c -r1.17 p-exp.y
*** gdb/p-exp.y	6 Nov 2002 22:48:25 -0000	1.17
--- gdb/p-exp.y	7 Nov 2002 19:57:18 -0000
***************
*** 141,147 ****
      struct stoken sval;
      struct ttype tsym;
      struct symtoken ssym;
-     int voidval;
      struct block *bval;
      enum exp_opcode opcode;
      struct internalvar *ivar;
--- 141,146 ----
***************
*** 162,168 ****
  static int search_field;
  %}
  
- %type <voidval> exp exp1 type_exp start normal_start variable qualified_name
  %type <tval> type typebase
  /* %type <bval> block */
  
--- 161,166 ----
***************
*** 200,206 ****
  /* Special type cases, put in to allow the parser to distinguish different
     legal basetypes.  */
  
! %token <voidval> VARIABLE
  
  
  /* Object pascal */
--- 198,204 ----
  /* Special type cases, put in to allow the parser to distinguish different
     legal basetypes.  */
  
! %token VARIABLE
  
  
  /* Object pascal */
***************
*** 233,239 ****
  start   :	{ current_type = NULL;
  		  search_field = 0;
  		}
! 		normal_start {}
  	;
  
  normal_start	:
--- 231,237 ----
  start   :	{ current_type = NULL;
  		  search_field = 0;
  		}
! 		normal_start
  	;
  
  normal_start	:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]