This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix two Wcast-qual violations 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: Fri, 27 Jul 2007 04:10:20 -0400 (EDT)
- Subject: [PATCH]: Fix two Wcast-qual violations in java dir
This patch addresses the remaining -Wcast-qual warnings in the java
directory. Both cases involved taking substrings of const objects by
inserting a null at some point inside and passing that to get_identifier.
Afterwards, the original char was restored. IMHO, "putting it back the
way it was" is not the same as not modifying the object. :-)
In the first case, I replaced the null insertion plus call to
get_identifier with a call to get_identifier_with_length(). In the second
case, the function violating const-ness was unused so I zapped it.
Tested on sparc-sun-solaris2.10, no regressions.
Okay for mainline?
Thanks,
--Kaveh
2007-07-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* mangle.c (set_type_package_list): Constify.
* verify-glue.c (vfy_make_string): Delete.
* verify.h (vfy_make_string): Likewise.
diff -rup orig/egcc-SVN20070725/gcc/java/mangle.c egcc-SVN20070725/gcc/java/mangle.c
--- orig/egcc-SVN20070725/gcc/java/mangle.c 2007-01-09 20:01:23.000000000 -0500
+++ egcc-SVN20070725/gcc/java/mangle.c 2007-07-26 12:39:40.682927427 -0400
@@ -749,27 +749,21 @@ set_type_package_list (tree type)
{
int i;
const char *type_string = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
- char *ptr;
+ const char *ptr;
int qualifications;
tree list = NULL_TREE, elt;
- for (ptr = (char *)type_string, qualifications = 0; *ptr; ptr++)
+ for (ptr = type_string, qualifications = 0; *ptr; ptr++)
if (*ptr == '.')
qualifications += 1;
- for (ptr = (char *)type_string, i = 0; i < qualifications; ptr++)
+ for (ptr = type_string, i = 0; i < qualifications; ptr++)
{
if (ptr [0] == '.')
{
- char c;
- tree identifier;
+ tree const identifier
+ = get_identifier_with_length (type_string, ptr - type_string);
- /* Can't use an obstack, we're already using it to
- accumulate the mangling. */
- c = ptr [0];
- ptr [0] = '\0';
- identifier = get_identifier (type_string);
- ptr [0] = c;
elt = build_tree_list (identifier, identifier);
TREE_CHAIN (elt) = list;
list = elt;
diff -rup orig/egcc-SVN20070725/gcc/java/verify-glue.c egcc-SVN20070725/gcc/java/verify-glue.c
--- orig/egcc-SVN20070725/gcc/java/verify-glue.c 2006-05-26 20:00:13.000000000 -0400
+++ egcc-SVN20070725/gcc/java/verify-glue.c 2007-07-26 12:33:50.415857654 -0400
@@ -211,18 +211,6 @@ vfy_get_pool_class (vfy_constants *pool,
}
vfy_string
-vfy_make_string (const char *s, int len)
-{
- tree result;
- char *s2 = (char *) s;
- char save = s2[len];
- s2[len] = '\0';
- result = get_identifier (s2);
- s2[len] = save;
- return result;
-}
-
-vfy_string
vfy_get_class_name (vfy_jclass klass)
{
return DECL_NAME (TYPE_NAME (klass));
diff -rup orig/egcc-SVN20070725/gcc/java/verify.h egcc-SVN20070725/gcc/java/verify.h
--- orig/egcc-SVN20070725/gcc/java/verify.h 2006-05-26 20:00:15.000000000 -0400
+++ egcc-SVN20070725/gcc/java/verify.h 2007-07-26 12:34:33.995676529 -0400
@@ -97,7 +97,6 @@ vfy_constants *vfy_get_constants (vfy_jc
int vfy_get_constants_size (vfy_jclass klass);
vfy_string vfy_get_pool_string (vfy_constants *pool, int index);
vfy_jclass vfy_get_pool_class (vfy_constants *pool, int index);
-vfy_string vfy_make_string (const char *s, int len);
vfy_string vfy_get_class_name (vfy_jclass klass);
bool vfy_is_assignable_from (vfy_jclass target, vfy_jclass source);
char vfy_get_primitive_char (vfy_jclass klass);