All Java methods treated as varargs

Jonathan P. Olson olson@mmsi.com
Sat Sep 19 10:32:00 GMT 1998


Turns out that gcj was treating all Java methods as C `stdarg' methods.
Note the following code from function.c:assign_parms()
 /* Nonzero if function takes extra anonymous args.
 This means the last named arg must be on the stack
 right before the anonymous ones. */
 int stdarg
 = (TYPE_ARG_TYPES (fntype) != 0
 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
	 != void_type_node));
What this does is assume that any argument list that doesn't end with
a `void_type_node' is treated as a variable length argument list. I added
the following patch to <gcc/java/decl.c> that should fixup the problem.
Check and make sure that it doesn't have any undesirable side effects:
*** egcs-19980906/gcc/java/decl.c.orig	Sun Sep 6 08:36:07 1998
--- egcs-19980906/gcc/java/decl.c	Sat Sep 19 08:45:44 1998
***************
*** 1516,1523 ****
 	}
 }
 *ptr = NULL_TREE;
- DECL_ARG_SLOT_COUNT (current_function_decl) = i;
 
 while (i < DECL_MAX_LOCALS(fndecl))
 type_map[i++] = NULL_TREE;
 
--- 1516,1533 ----
 	}
 }
 *ptr = NULL_TREE;
 
+ /* We need an extra `void' at the end of our parameter list so
+ that assign_parms() doesn't think that this is a variable length
+ argument list. */
+ 
+ if (i)
+ {
+ tem = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
+ TREE_CHAIN (tem) = perm_tree_cons (NULL_TREE, void_type_node, NULL_TREE);
+ }
+ 
+ DECL_ARG_SLOT_COUNT (current_function_decl) = i;
 while (i < DECL_MAX_LOCALS(fndecl))
 type_map[i++] = NULL_TREE;
 
--
Jon Olson, Modular Mining Systems
	 3289 E. Hemisphere Loop
	 Tucson, AZ 85706
INTERNET: olson@mmsi.com
PHONE: (520)746-9127
FAX: (520)889-5790


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /