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: Java: Fix PR 16701


Andrew Haley wrote:

Bryce McKinlay writes:
> This patch fixes PR 16701. fold_constant_for_init() recursively resolves > other constants, but it didn't update the global current_class before > calling resolve_field_access(). This resulted in access checks being > performed from the wrong context.


I think you need to check the return value of resolve_field_access().
If resolve_field_access() fails returning error_mark_node, no-one has
initialized decl.


I agree. Note that the original code had this bug too. I've checked in this variant which adds a check for an error_mark_node return value from resolve_field_access (resolve_field_access should never return NULL, only a valid decl or error_mark_node)

Regards

Bryce

2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>

	PR java/16701
	* parse.y (fold_constant_for_init): Call resolve_field_access with
	correct current_class context.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.496
diff -u -r1.496 parse.y
--- parse.y	26 Jul 2004 11:15:09 -0000	1.496
+++ parse.y	2 Aug 2004 18:02:02 -0000
@@ -15969,16 +15969,16 @@
 	    }
 	  else
 	    {
-	      /* Install the proper context for the field resolution.
-		 The prior context is restored once the name is
-		 properly qualified. */
+	      tree r = NULL_TREE;
+	      /* Install the proper context for the field resolution.  */
 	      tree saved_current_class = current_class;
 	      /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
 	      current_class = DECL_CONTEXT (context);
 	      qualify_ambiguous_name (node);
+	      r = resolve_field_access (node, &decl, NULL);
+	      /* Restore prior context.  */
 	      current_class = saved_current_class;
-	      if (resolve_field_access (node, &decl, NULL)
-		  && decl != NULL_TREE)
+	      if (r != error_mark_node && decl != NULL_TREE)
 		return fold_constant_for_init (decl, decl);
 	      return NULL_TREE;
 	    }

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