C++ bootstrap (part 11/n): Add casts from void *

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Jul 26 05:19:00 GMT 2004


Bernardo Innocenti <bernie@develer.com> writes:

[...]

| -      tlist_firstobj = obstack_alloc (&tlist_obstack, 0);
| +      tlist_firstobj = (char *) obstack_alloc (&tlist_obstack, 0);

Why isn't this an XOBNEW?

The rationale of all these macros is that we should not have to
springle casts everywhere when we allocate storage.

[...]

| -      if (op == SIZEOF_EXPR)
| +      if (op == (enum tree_code) SIZEOF_EXPR)

Why this?

[...]

| -	  char *newp = alloca (len - 1);
| +	  char *newp = (char *) alloca (len - 1);

We should have a macro for this, similar to XNEW.  XALLOCA?

[...]

| -      char *starred = alloca (strlen (asmspec) + 2);
| +      char *starred = (char *) alloca (strlen (asmspec) + 2);

Ditto.

[...]

| -  copy = alloca (copylen + 1);
| +  copy = (char *) alloca (copylen + 1);

Ditto.

|    memcpy (copy, token->val.str.text, copylen);
|    copy[copylen] = '\0';
|  
| @@ -710,7 +710,7 @@ lex_string (const cpp_token *tok, tree *
|  	    }
|  	}
|        while (tok->type == CPP_STRING || tok->type == CPP_WSTRING);
| -      strs = obstack_finish (&str_ob);
| +      strs = (cpp_string *) obstack_finish (&str_ob);

This should be an XOBNEW.

[...]

| -      char *newname = alloca (plen + ilen + 1);
| +      char *newname = (char *) alloca (plen + ilen + 1);

Same comments as before.

[...]

| -	      new_opname = alloca (IDENTIFIER_LENGTH (function)
| +	      new_opname = (char *) alloca (IDENTIFIER_LENGTH (function)
|  				   + strlen (argstring) + 1 + 1);

Ditto.

[...]

| -	      new_opname = alloca (strlen (argnofun) + 1 + 1);
| +	      new_opname = (char *) alloca (strlen (argnofun) + 1 + 1);

Ditto.

[...]

| -	  new_opname = alloca (IDENTIFIER_LENGTH (function)
| +	  new_opname = (char *) alloca (IDENTIFIER_LENGTH (function)
|  			       + strlen (argstring) + 1 + 25 /*%d*/ + 1);

Ditto.

[...]

| -	  new_opname = alloca (strlen (argnofun) + 1 + 25 /*%d*/ + 1);
| +	  new_opname = (char *) alloca (strlen (argnofun) + 1 + 25 /*%d*/ + 1);

Ditto.

[...]

| -  ofwhat = print_spelling (alloca (spelling_length () + 1));
| +  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));

Ditto.

[...]

| -  ofwhat = print_spelling (alloca (spelling_length () + 1));
| +  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));


[...]

| -  ofwhat = print_spelling (alloca (spelling_length () + 1));
| +  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
|    if (*ofwhat)

[...]

| -  tree *o = alloca (noutputs * sizeof (tree));
| +  tree *o = (tree *) alloca (noutputs * sizeof (tree));

[...]

| -       char *const output_ = (OUTPUT) = alloca (strlen (name_) + 32);\
| +       char *const output_ = (OUTPUT) = \
| +	 (char *) alloca (strlen (name_) + 32); \

[...]

| -  return obstack_finish (ob);
| +  return (char *) obstack_finish (ob);

We should have a macro for this.

[...]

| -  return obstack_finish (ob);
| +  return (char *) obstack_finish (ob);

-- Gaby



More information about the Gcc-patches mailing list