This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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: Patch: incorrect hardcoding of java's modifier_ctx array size


 > From: Tom Tromey <tromey@redhat.com>
 > 
 > >>>>> "Kaveh" == Kaveh R Ghazi <ghazi@caip.rutgers.edu> writes:
 > 
 > Kaveh> While grepping for places to use ARRAY_SIZE, I noticed some
 > Kaveh> incorrect hardcoding of the size of java's
 > Kaveh> parser_ctxt.modifier_ctx[] array.  See:
 > Kaveh> http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01675.html for
 > Kaveh> some history.
 > 
 > There hasn't been any reply to this patch yet.
 > Kaveh, I think it is fine.  I'd say it even qualifies as obvious.
 > 
 > Would you mind taking a quick look to see if we already have problems
 > with this particular hard-coding?  I bet searching for `10' in the
 > sources will unfortunately :-( turn up a couple problems.
 > Tom

Ok I installed it on the trunk along with this one generated by
searching for "10" in the java dir.  I still don't know whether this
one and the previous are appropriate for the branch or not.  Tom would
you care to comment on that?

		--Kaveh


2002-06-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* parse.y (check_modifiers, declare_local_variables): Avoid
	incorrect hardcoded constant 10.

diff -ru6p orig/egcc-CVS20020625/gcc/java/parse.y egcc-CVS20020625/gcc/java/parse.y
--- orig/egcc-CVS20020625/gcc/java/parse.y	2002-06-13 16:01:03.000000000 -0400
+++ egcc-CVS20020625/gcc/java/parse.y	2002-06-26 21:10:52.283647081 -0400
@@ -437,14 +437,14 @@ static GTY(()) tree src_parse_roots[1];
 /* Should point out the one that don't fit. ASCII/unicode, going
    backward. FIXME */
 
 #define check_modifiers(__message, __value, __mask) do {	\
   if ((__value) & ~(__mask))					\
     {								\
-      int i, remainder = (__value) & ~(__mask);			\
-      for (i = 0; i <= 10; i++)					\
+      size_t i, remainder = (__value) & ~(__mask);	       	\
+      for (i = 0; i < ARRAY_SIZE (ctxp->modifier_ctx); i++)	\
         if ((1 << i) & remainder)				\
 	  parse_error_context (ctxp->modifier_ctx [i], (__message), \
 			       java_accstring_lookup (1 << i)); \
     }								\
 } while (0)
 
@@ -7245,14 +7245,16 @@ declare_local_variables (modifier, type,
       tree b = enter_block ();
       BLOCK_IS_IMPLICIT (b) = 1;
     }
 
   if (modifier)
     {
-      int i;
-      for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
+      size_t i;
+      for (i = 0; i < ARRAY_SIZE (ctxp->modifier_ctx); i++)
+	if (1 << i & modifier)
+	  break;
       if (modifier == ACC_FINAL)
 	final_p = 1;
       else
 	{
 	  parse_error_context
 	    (ctxp->modifier_ctx [i],


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