* [PATCH]: Fix two Wcast-qual violations in java dir
@ 2007-07-27 9:07 Kaveh R. GHAZI
2007-07-27 15:27 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Kaveh R. GHAZI @ 2007-07-27 9:07 UTC (permalink / raw)
To: gcc-patches, java-patches
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH]: Fix two Wcast-qual violations in java dir
2007-07-27 9:07 [PATCH]: Fix two Wcast-qual violations in java dir Kaveh R. GHAZI
@ 2007-07-27 15:27 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2007-07-27 15:27 UTC (permalink / raw)
To: Kaveh R. GHAZI; +Cc: gcc-patches, java-patches
>>>>> "Kaveh" == Kaveh R GHAZI <ghazi@caip.rutgers.edu> writes:
Kaveh> This patch addresses the remaining -Wcast-qual warnings in the
Kaveh> java directory.
Kaveh> Okay for mainline?
Yes, thanks.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-27 14:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-27 9:07 [PATCH]: Fix two Wcast-qual violations in java dir Kaveh R. GHAZI
2007-07-27 15:27 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).