This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Patch: PR 5942


This patch fixes PR 5942.

The array was incorrectly sized; when I added strictfp support I
forgot to make it bigger.

Ideally instead of `[12]' we would write `[MODIFIER_TK - PUBLIC_TK]'.
However that isn't possible as those values are defined only in parse.c.
So instead I just added a sanity check elsewhere.
This way we'll get an abort if this error ever occurs again.

I took a cursory look for other constant-sized arrays, but I couldn't
find any.  Well, actually, there is the mysterious operand_type[] in
expr.c (the initialization of this array is particularly, umm, nice).

Alex, is this ok?

Tom


Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	Fix for PR java/5942:
	* parse.y (init_src_parse): Added sanity check.
	* parse.h (struct parser_ctxt) [modifier_ctx]: Array has 12
	elements, not 11.

Index: parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.82
diff -u -r1.82 parse.h
--- parse.h 2002/02/18 04:55:07 1.82
+++ parse.h 2002/03/26 07:14:18
@@ -762,7 +762,7 @@
 
   /* This section is defined only if we compile jc1 */
 #ifndef JC1_LITE
-  tree modifier_ctx [11];	    /* WFL of modifiers */
+  tree modifier_ctx [12];	    /* WFL of modifiers */
   tree class_type;		    /* Current class */
   tree function_decl;	            /* Current function decl, save/restore */
 
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.353.2.8
diff -u -r1.353.2.8 parse.y
--- parse.y 2002/03/21 18:56:58 1.353.2.8
+++ parse.y 2002/03/26 07:14:28
@@ -16013,6 +16013,11 @@
 {
   /* Register roots with the garbage collector.  */
   ggc_add_tree_root (src_parse_roots, sizeof (src_parse_roots) / sizeof(tree));
+
+  /* Sanity check; we've been bit by this before.  */
+  if (sizeof (ctxp->modifier_ctx) / sizeof (tree) != 
+      MODIFIER_TK - PUBLIC_TK)
+    abort ();
 }
 
 


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