This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[thread-annotations] [patch] fix -Wcast-qual warnings
- From: "Le-Chun Wu" <lcwu at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 Jul 2008 16:39:53 -0700
- Subject: [thread-annotations] [patch] fix -Wcast-qual warnings
This patch fixes the compilation warnings due to the use of
"-Wcast-qual -Wc++-compat" flags. The patch is for the
thread-annotations branch. Bootstrapped and
tested on i686-linux-gnu.
Le-chun
2008-07-02 Le-Chun Wu <lcwu@google.com>
* tree-threadsafe-analyze.c (dump_expr_tree): Fix -Wcast-qual and/or
-Wc++-compat warnings.
(match_locks): Ditto.
(check_acquired_after): Ditto.
(check_locking_order): Ditto.
(handle_unlock_primitive_attr): Ditto.
(warn_locally_unreleased_locks): Ditto.
(warn_unreleased_locks): Ditto.
* gcc/tree-threadsafe-analyze.h: Fix -Wcast-qual and/or -Wc++-compat
warnings.
Index: gcc/tree-threadsafe-analyze.c
===================================================================
--- gcc/tree-threadsafe-analyze.c (revision 137323)
+++ gcc/tree-threadsafe-analyze.c (working copy)
@@ -760,7 +760,7 @@ get_canonical_expr (tree lock, bool is_t
we use the tree pretty print mechanism to do that. */
const char*
-dump_expr_tree (const tree lock, char *out_buf)
+dump_expr_tree (tree lock, char *out_buf)
{
if (DECL_P (lock) && DECL_NAME (lock))
snprintf(out_buf, LOCK_NAME_LEN, "'%s'",
@@ -1000,7 +1000,7 @@ static bool
match_locks (const void *lock, void *info)
{
struct lock_match_info *match_info = (struct lock_match_info *)info;
- tree acq_after_lock = (tree) lock;
+ tree acq_after_lock = CONST_CAST_TREE ((const_tree) lock);
bool result = true;
if (TREE_CODE (acq_after_lock) == FIELD_DECL)
@@ -1126,7 +1126,7 @@ check_acquired_after (const void *live_l
tree lock_decl;
tree base;
void **entry;
- tree live_lock_tree = (tree) live_lock;
+ tree live_lock_tree = CONST_CAST_TREE ((const_tree) live_lock);
tree live_lock_decl;
bool live_lock_in_locks_acq_after_set;
bool lock_in_live_locks_acq_after_set;
@@ -1185,14 +1185,14 @@ check_acquired_after (const void *live_l
warning (OPT_Wthread_safety,
G_("%HLock %s is acquired after lock %s (acquired at"
" line %d) but is annotated otherwise"),
- current_loc, dump_expr_tree ((const tree) lock, lname1),
+ current_loc, dump_expr_tree ((tree) lock, lname1),
dump_expr_tree (live_lock_tree, lname2),
LOCATION_LINE (*((location_t *) *loc_entry)));
else
warning (OPT_Wthread_safety,
G_("%HLock %s is acquired after lock %s (held at function"
" entry) but is annotated otherwise"),
- current_loc, dump_expr_tree ((const tree) lock, lname1),
+ current_loc, dump_expr_tree ((tree) lock, lname1),
dump_expr_tree (live_lock_tree, lname2));
}
return true;
@@ -1214,7 +1214,7 @@ check_acquired_after (const void *live_l
is acquired. */
static void
-check_locking_order (const tree lock,
+check_locking_order (tree lock,
const struct pointer_set_t *live_excl_locks,
const struct pointer_set_t *live_shared_locks,
const location_t *locus)
@@ -1459,7 +1459,7 @@ handle_unlock_primitive_attr (tree call,
void **entry = pointer_map_contains (scopedlock_to_lock_map,
scoped_lock);
if (entry)
- lockable = *entry;
+ lockable = (tree) *entry;
}
}
/* If the function is not a destructor of a scoped_lock, base_obj
@@ -2261,7 +2261,7 @@ warn_locally_unreleased_locks (const voi
{
char lname[LOCK_NAME_LEN];
void **entry;
- tree lock_tree = (tree) lock;
+ tree lock_tree = CONST_CAST_TREE ((const_tree) lock);
location_t *loc;
struct pointer_set_t *reported_unreleased_locks;
@@ -2312,7 +2312,7 @@ warn_unreleased_locks (const void *lock,
{
char lname[LOCK_NAME_LEN];
void **entry = pointer_map_contains (lock_locus_map, lock);
- tree lock_tree = (tree) lock;
+ tree lock_tree = CONST_CAST_TREE ((const_tree) lock);
location_t *loc;
gcc_assert (entry);
loc = (location_t *) *entry;
Index: gcc/tree-threadsafe-analyze.h
===================================================================
--- gcc/tree-threadsafe-analyze.h (revision 137323)
+++ gcc/tree-threadsafe-analyze.h (working copy)
@@ -29,6 +29,6 @@ along with GCC; see the file COPYING3.
extern void clean_up_threadsafe_analysis (void);
extern struct pointer_map_t *lock_acquired_after_map;
extern struct pointer_map_t *unbound_lock_map;
-extern const char* dump_expr_tree (const tree lock, char *out_buf);
+extern const char* dump_expr_tree (tree lock, char *out_buf);
#endif /* TREE_THREADSAFE_ANALYZE_H */