re PR middle-end/36509 (gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c)
2008-12-04 Richard Guenther <rguenther@suse.de> PR middle-end/36509 PR c++/38334 * Makefile.in (tree-ssa-alias-warnings.o): Remove. (tree-ssa-structalias.o): Remove errors.h dependency. (tree-ssa-reassoc.o): Likewise. * tree-ssa-reassoc.c: Do not include errors.h. * tree-ssa-alias-warnings.c: Remove. * tree-ssa-alias.c (compute_may_aliases): Remove call to strict_aliasing_warning_backend. * tree-ssa-structalias.c (emit_pointer_definition): New function. (emit_alias_warning): Likewise. (set_uids_in_ptset): Warn for clear cases of type-punning. * tree-inline.c (remap_gimple_op_r): Preserve TREE_NO_WARNING on INDIRECT_REFs. cp/ * typeck.c (get_member_function_from_ptrfunc): Mark the vtbl pointer access with TREE_NO_WARNING. * gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c: Adjust, remove XFAIL. * gcc.dg/Wstrict-aliasing-converted-assigned.c: Adjust. * g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C: Likewise. From-SVN: r142437
This commit is contained in:
parent
a4781348e2
commit
ce1b649802
@ -1,3 +1,19 @@
|
||||
2008-12-04 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR middle-end/36509
|
||||
* Makefile.in (tree-ssa-alias-warnings.o): Remove.
|
||||
(tree-ssa-structalias.o): Remove errors.h dependency.
|
||||
(tree-ssa-reassoc.o): Likewise.
|
||||
* tree-ssa-reassoc.c: Do not include errors.h.
|
||||
* tree-ssa-alias-warnings.c: Remove.
|
||||
* tree-ssa-alias.c (compute_may_aliases): Remove call to
|
||||
strict_aliasing_warning_backend.
|
||||
* tree-ssa-structalias.c (emit_pointer_definition): New function.
|
||||
(emit_alias_warning): Likewise.
|
||||
(set_uids_in_ptset): Warn for clear cases of type-punning.
|
||||
* tree-inline.c (remap_gimple_op_r): Preserve TREE_NO_WARNING
|
||||
on INDIRECT_REFs.
|
||||
|
||||
2008-12-04 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* cse.c (equiv_constant): Fix pasto.
|
||||
|
@ -1243,7 +1243,6 @@ OBJS-common = \
|
||||
tree-switch-conversion.o \
|
||||
tree-ssa-address.o \
|
||||
tree-ssa-alias.o \
|
||||
tree-ssa-alias-warnings.o \
|
||||
tree-ssa-ccp.o \
|
||||
tree-ssa-coalesce.o \
|
||||
tree-ssa-copy.o \
|
||||
@ -2089,7 +2088,7 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
|
||||
$(TOPLEV_H)
|
||||
tree-ssa-structalias.o: tree-ssa-structalias.c tree-ssa-structalias.h \
|
||||
$(SYSTEM_H) $(CONFIG_H) coretypes.h $(TM_H) $(GGC_H) $(OBSTACK_H) $(BITMAP_H) \
|
||||
$(FLAGS_H) $(RTL_H) $(TM_P_H) hard-reg-set.h $(BASIC_BLOCK_H) output.h errors.h \
|
||||
$(FLAGS_H) $(RTL_H) $(TM_P_H) hard-reg-set.h $(BASIC_BLOCK_H) output.h \
|
||||
$(DIAGNOSTIC_H) $(TREE_H) $(C_COMMON_H) $(TREE_FLOW_H) $(TREE_INLINE_H) varray.h \
|
||||
$(C_TREE_H) $(GIMPLE_H) $(HASHTAB_H) $(FUNCTION_H) $(CGRAPH_H) tree-pass.h \
|
||||
$(TIMEVAR_H) alloc-pool.h $(SPLAY_TREE_H) $(PARAMS_H) gt-tree-ssa-structalias.h \
|
||||
@ -2309,11 +2308,6 @@ tree-ssa-loop-im.o : tree-ssa-loop-im.c $(TREE_FLOW_H) $(CONFIG_H) \
|
||||
tree-ssa-math-opts.o : tree-ssa-math-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||
$(TM_H) $(FLAGS_H) $(TREE_H) $(TREE_FLOW_H) $(REAL_H) $(TIMEVAR_H) tree-pass.h \
|
||||
alloc-pool.h $(BASIC_BLOCK_H) $(TARGET_H)
|
||||
tree-ssa-alias-warnings.o : tree-ssa-alias-warnings.c \
|
||||
$(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(TREE_DUMP_H) \
|
||||
$(TREE_FLOW_H) $(PARAMS_H) $(FUNCTION_H) $(EXPR_H) $(TOPLEV_H) \
|
||||
tree-ssa-structalias.h tree-ssa-propagate.h langhooks.h alloc-pool.h \
|
||||
$(DIAGNOSTIC_H)
|
||||
tree-ssa-alias.o : tree-ssa-alias.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
|
||||
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) $(TREE_INLINE_H) $(FLAGS_H) \
|
||||
$(FUNCTION_H) $(TIMEVAR_H) convert.h $(TM_H) coretypes.h langhooks.h \
|
||||
@ -2321,7 +2315,7 @@ tree-ssa-alias.o : tree-ssa-alias.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
|
||||
hard-reg-set.h $(GIMPLE_H) vec.h tree-ssa-structalias.h \
|
||||
$(IPA_TYPE_ESCAPE_H) vecprim.h pointer-set.h alloc-pool.h
|
||||
tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
|
||||
$(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TIMEVAR_H) \
|
||||
$(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
|
||||
$(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) tree-iterator.h\
|
||||
$(BASIC_BLOCK_H) $(GIMPLE_H) $(TREE_INLINE_H) vec.h langhooks.h \
|
||||
alloc-pool.h pointer-set.h $(CFGLOOP_H)
|
||||
|
@ -1,3 +1,9 @@
|
||||
2008-12-04 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR c++/38334
|
||||
* typeck.c (get_member_function_from_ptrfunc): Mark the vtbl
|
||||
pointer access with TREE_NO_WARNING.
|
||||
|
||||
2008-12-03 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/38232
|
||||
|
@ -2790,6 +2790,10 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
|
||||
vtbl = build1 (NOP_EXPR, build_pointer_type (vtbl_ptr_type_node),
|
||||
instance_ptr);
|
||||
vtbl = cp_build_indirect_ref (vtbl, NULL, tf_warning_or_error);
|
||||
/* If the object is not dynamic the access invokes undefined
|
||||
behavior. As it is not executed in this case silence the
|
||||
spurious warnings it may provoke. */
|
||||
TREE_NO_WARNING (vtbl) = 1;
|
||||
|
||||
/* Finally, extract the function pointer from the vtable. */
|
||||
e2 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (vtbl), vtbl,
|
||||
|
@ -1,3 +1,10 @@
|
||||
2008-12-04 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR middle-end/36509
|
||||
* gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c: Adjust, remove XFAIL.
|
||||
* gcc.dg/Wstrict-aliasing-converted-assigned.c: Adjust.
|
||||
* g++.dg/warn/Wstrict-aliasing-float-ref-int-obj.C: Likewise.
|
||||
|
||||
2008-12-04 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc.dg/union-4.c: New test.
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
int foo() {
|
||||
int x;
|
||||
float& q = reinterpret_cast<float&> (x); /* { dg-warning "type-punn" } */
|
||||
q = 1.0;
|
||||
float& q = reinterpret_cast<float&> (x); /* { dg-message "initialized" } */
|
||||
q = 1.0; /* { dg-warning "does break strict-aliasing" } */
|
||||
return x;
|
||||
}
|
||||
|
||||
/* { dg-message "dereferencing type-punned" "" { target *-*-* } 7 } */
|
||||
|
@ -8,3 +8,6 @@ int foo()
|
||||
*(long*)&i = 0; /* { dg-warning "type-punn" } */
|
||||
return i;
|
||||
}
|
||||
|
||||
/* { dg-message "does break strict-aliasing" "" { target *-*-* } 8 } */
|
||||
/* { dg-message "initialized" "" { target *-*-* } 8 } */
|
||||
|
@ -11,12 +11,12 @@ int foo() {
|
||||
float* r;
|
||||
|
||||
if (flag) {
|
||||
q = (float*) &x; /* { dg-warning "type-punn" "" { xfail *-*-* } } */
|
||||
q = (float*) &x; /* { dg-message "initialized" } */
|
||||
} else {
|
||||
q = (float*) &y; /* { dg-warning "type-punn" "" { xfail *-*-* } } */
|
||||
q = (float*) &y; /* { dg-message "initialized" } */
|
||||
}
|
||||
|
||||
*q = 1.0;
|
||||
*q = 1.0; /* { dg-warning "does break strict-aliasing" } */
|
||||
|
||||
return x;
|
||||
|
||||
|
@ -710,6 +710,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
|
||||
{
|
||||
*tp = build1 (INDIRECT_REF, type, new_tree);
|
||||
TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
|
||||
TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old);
|
||||
}
|
||||
}
|
||||
*walk_subtrees = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1825,9 +1825,6 @@ compute_may_aliases (void)
|
||||
dump_referenced_vars (dump_file);
|
||||
}
|
||||
|
||||
/* Report strict aliasing violations. */
|
||||
strict_aliasing_warning_backend ();
|
||||
|
||||
/* Deallocate memory used by aliasing data structures. */
|
||||
delete_alias_info (ai);
|
||||
|
||||
|
@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tm.h"
|
||||
#include "errors.h"
|
||||
#include "ggc.h"
|
||||
#include "tree.h"
|
||||
#include "basic-block.h"
|
||||
|
@ -31,14 +31,14 @@
|
||||
#include "hard-reg-set.h"
|
||||
#include "basic-block.h"
|
||||
#include "output.h"
|
||||
#include "errors.h"
|
||||
#include "diagnostic.h"
|
||||
#include "tree.h"
|
||||
#include "c-common.h"
|
||||
#include "tree-flow.h"
|
||||
#include "tree-inline.h"
|
||||
#include "varray.h"
|
||||
#include "c-tree.h"
|
||||
#include "diagnostic.h"
|
||||
#include "toplev.h"
|
||||
#include "gimple.h"
|
||||
#include "hashtab.h"
|
||||
#include "function.h"
|
||||
@ -4648,14 +4648,15 @@ shared_bitmap_add (bitmap pt_vars)
|
||||
IS_DEREFED is true if PTR was directly dereferenced, which we use to
|
||||
help determine whether we are we are allowed to prune using TBAA.
|
||||
If NO_TBAA_PRUNING is true, we do not perform any TBAA pruning of
|
||||
the from set. */
|
||||
the from set. Returns the number of pruned variables. */
|
||||
|
||||
static void
|
||||
static unsigned
|
||||
set_uids_in_ptset (tree ptr, bitmap into, bitmap from, bool is_derefed,
|
||||
bool no_tbaa_pruning)
|
||||
{
|
||||
unsigned int i;
|
||||
bitmap_iterator bi;
|
||||
unsigned pruned = 0;
|
||||
|
||||
gcc_assert (POINTER_TYPE_P (TREE_TYPE (ptr)));
|
||||
|
||||
@ -4688,14 +4689,97 @@ set_uids_in_ptset (tree ptr, bitmap into, bitmap from, bool is_derefed,
|
||||
if (may_alias_p (SSA_NAME_VAR (ptr), mem_alias_set,
|
||||
vi->decl, var_alias_set, true))
|
||||
bitmap_set_bit (into, DECL_UID (vi->decl));
|
||||
else
|
||||
++pruned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pruned;
|
||||
}
|
||||
|
||||
|
||||
static bool have_alias_info = false;
|
||||
|
||||
/* Emit a note for the pointer initialization point DEF. */
|
||||
|
||||
static void
|
||||
emit_pointer_definition (gimple def)
|
||||
{
|
||||
if (gimple_code (def) == GIMPLE_PHI)
|
||||
{
|
||||
use_operand_p argp;
|
||||
ssa_op_iter oi;
|
||||
|
||||
FOR_EACH_PHI_ARG (argp, def, oi, SSA_OP_USE)
|
||||
{
|
||||
tree arg = USE_FROM_PTR (argp);
|
||||
if (TREE_CODE (arg) == SSA_NAME)
|
||||
emit_pointer_definition (SSA_NAME_DEF_STMT (arg));
|
||||
else
|
||||
inform (0, "initialized from %qE", arg);
|
||||
}
|
||||
}
|
||||
else if (!gimple_nop_p (def))
|
||||
inform (gimple_location (def), "initialized from here");
|
||||
}
|
||||
|
||||
/* Emit a strict aliasing warning for dereferencing the pointer PTR. */
|
||||
|
||||
static void
|
||||
emit_alias_warning (tree ptr)
|
||||
{
|
||||
gimple def = SSA_NAME_DEF_STMT (ptr);
|
||||
gimple use;
|
||||
imm_use_iterator ui;
|
||||
unsigned warned = 0;
|
||||
|
||||
FOR_EACH_IMM_USE_STMT (use, ui, ptr)
|
||||
{
|
||||
tree deref = NULL_TREE;
|
||||
|
||||
if (gimple_has_lhs (use))
|
||||
{
|
||||
tree lhs = get_base_address (gimple_get_lhs (use));
|
||||
if (lhs
|
||||
&& INDIRECT_REF_P (lhs)
|
||||
&& TREE_OPERAND (lhs, 0) == ptr)
|
||||
deref = lhs;
|
||||
}
|
||||
if (gimple_assign_single_p (use))
|
||||
{
|
||||
tree rhs = get_base_address (gimple_assign_rhs1 (use));
|
||||
if (rhs
|
||||
&& INDIRECT_REF_P (rhs)
|
||||
&& TREE_OPERAND (rhs, 0) == ptr)
|
||||
deref = rhs;
|
||||
}
|
||||
else if (is_gimple_call (use))
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < gimple_call_num_args (use); ++i)
|
||||
{
|
||||
tree op = get_base_address (gimple_call_arg (use, i));
|
||||
if (op
|
||||
&& INDIRECT_REF_P (op)
|
||||
&& TREE_OPERAND (op, 0) == ptr)
|
||||
deref = op;
|
||||
}
|
||||
}
|
||||
if (deref
|
||||
&& !TREE_NO_WARNING (deref))
|
||||
{
|
||||
TREE_NO_WARNING (deref) = 1;
|
||||
warning_at (gimple_location (use), OPT_Wstrict_aliasing,
|
||||
"dereferencing pointer %qD does break strict-aliasing "
|
||||
"rules", SSA_NAME_VAR (ptr));
|
||||
++warned;
|
||||
}
|
||||
}
|
||||
if (warned > 0)
|
||||
emit_pointer_definition (def);
|
||||
}
|
||||
|
||||
/* Given a pointer variable P, fill in its points-to set, or return
|
||||
false if we can't.
|
||||
Rather than return false for variables that point-to anything, we
|
||||
@ -4740,7 +4824,7 @@ find_what_p_points_to (tree p)
|
||||
else
|
||||
{
|
||||
struct ptr_info_def *pi = get_ptr_info (p);
|
||||
unsigned int i;
|
||||
unsigned int i, pruned;
|
||||
bitmap_iterator bi;
|
||||
bool was_pt_anything = false;
|
||||
bitmap finished_solution;
|
||||
@ -4792,9 +4876,9 @@ find_what_p_points_to (tree p)
|
||||
finished_solution = BITMAP_GGC_ALLOC ();
|
||||
stats.points_to_sets_created++;
|
||||
|
||||
set_uids_in_ptset (p, finished_solution, vi->solution,
|
||||
pi->is_dereferenced,
|
||||
vi->no_tbaa_pruning);
|
||||
pruned = set_uids_in_ptset (p, finished_solution, vi->solution,
|
||||
pi->is_dereferenced,
|
||||
vi->no_tbaa_pruning);
|
||||
result = shared_bitmap_lookup (finished_solution);
|
||||
|
||||
if (!result)
|
||||
@ -4809,7 +4893,22 @@ find_what_p_points_to (tree p)
|
||||
}
|
||||
|
||||
if (bitmap_empty_p (pi->pt_vars))
|
||||
pi->pt_vars = NULL;
|
||||
{
|
||||
pi->pt_vars = NULL;
|
||||
if (pruned > 0
|
||||
&& pi->is_dereferenced
|
||||
&& warn_strict_aliasing > 0
|
||||
&& !SSA_NAME_IS_DEFAULT_DEF (p))
|
||||
{
|
||||
if (dump_file && dump_flags & TDF_DETAILS)
|
||||
{
|
||||
fprintf (dump_file, "alias warning for ");
|
||||
print_generic_expr (dump_file, p, 0);
|
||||
fprintf (dump_file, "\n");
|
||||
}
|
||||
emit_alias_warning (p);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user