This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch installed to eliminate useless casts in java dir
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Thu, 9 Jan 2003 22:39:18 -0500 (EST)
- Subject: Patch installed to eliminate useless casts in java dir
These casts were only necessary in K&R mode when xmalloc et al. would
return a "char *", aka "PTR". In ISO C (or GNUC) mode we always get a
"void *" so casts aren't necessary.
Feh, I just noticed that the decl.c hunk is missing from the patch
below. Ah well, it's in here:
http://gcc.gnu.org/ml/gcc-cvs/2003-01/msg00388.html
Pre-approved in private email by Andrew Haley
Tested on sparc-sun-solaris2.7.
2003-01-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* decl.c, parse-scan.y, parse.y: Don't cast return value of
xmalloc et al.
diff -rup orig/egcc-CVS20030109/gcc/java/parse-scan.y egcc-CVS20030109/gcc/java/parse-scan.y
--- orig/egcc-CVS20030109/gcc/java/parse-scan.y Thu Jan 9 18:13:20 2003
+++ egcc-CVS20030109/gcc/java/parse-scan.y Thu Jan 9 18:51:27 2003
@@ -109,8 +109,7 @@ struct method_declarator {
};
#define NEW_METHOD_DECLARATOR(D,N,A) \
{ \
- (D) = \
- (struct method_declarator *)xmalloc (sizeof (struct method_declarator)); \
+ (D) = xmalloc (sizeof (struct method_declarator)); \
(D)->method_name = (N); \
(D)->args = (A); \
}
@@ -1179,8 +1178,7 @@ constant_expression:
void
java_push_parser_context ()
{
- struct parser_ctxt *new =
- (struct parser_ctxt *) xcalloc (1, sizeof (struct parser_ctxt));
+ struct parser_ctxt *new = xcalloc (1, sizeof (struct parser_ctxt));
new->next = ctxp;
ctxp = new;
@@ -1192,7 +1190,7 @@ push_class_context (name)
{
struct class_context *ctx;
- ctx = (struct class_context *) xmalloc (sizeof (struct class_context));
+ ctx = xmalloc (sizeof (struct class_context));
ctx->name = (char *) name;
ctx->next = current_class_context;
current_class_context = ctx;
diff -rup orig/egcc-CVS20030109/gcc/java/parse.y egcc-CVS20030109/gcc/java/parse.y
--- orig/egcc-CVS20030109/gcc/java/parse.y Thu Jan 9 18:49:00 2003
+++ egcc-CVS20030109/gcc/java/parse.y Thu Jan 9 18:52:20 2003
@@ -2192,10 +2192,10 @@ dims:
{
allocate *= sizeof (int);
if (ctxp->osb_number)
- ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
- allocate);
+ ctxp->osb_number = xrealloc (ctxp->osb_number,
+ allocate);
else
- ctxp->osb_number = (int *)xmalloc (allocate);
+ ctxp->osb_number = xmalloc (allocate);
}
ctxp->osb_depth++;
CURRENT_OSB (ctxp) = 1;
@@ -2669,7 +2669,7 @@ create_new_parser_context (copy_from_pre
{
struct parser_ctxt *new;
- new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
+ new = xmalloc (sizeof (struct parser_ctxt));
if (copy_from_previous)
{
memcpy (new, ctxp, sizeof (struct parser_ctxt));
@@ -5148,7 +5148,7 @@ static void
create_jdep_list (ctxp)
struct parser_ctxt *ctxp;
{
- jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
+ jdeplist *new = xmalloc (sizeof (jdeplist));
new->first = new->last = NULL;
new->next = ctxp->classd_list;
ctxp->classd_list = new;
@@ -5203,7 +5203,7 @@ register_incomplete_type (kind, wfl, dec
int kind;
tree wfl, decl, ptr;
{
- jdep *new = (jdep *)xmalloc (sizeof (jdep));
+ jdep *new = xmalloc (sizeof (jdep));
if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
ptr = obtain_incomplete_type (wfl);