mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-11 17:54:48 +08:00
cp-objcp-common.c (cp_expr_size): Return NULL in the case size is undefined.
* cp-objcp-common.c (cp_expr_size): Return NULL in the case size is undefined. * builtins.c (fold_builtin_memory_op): Check that expr_size match. * explow.c (expr_size, int_expr_size): Assert that size is non_NULL. From-SVN: r119515
This commit is contained in:
parent
477d851ce1
commit
26979bc292
@ -1,3 +1,8 @@
|
||||
2006-12-04 Jan Hubicka <jh@suse.cz>
|
||||
|
||||
* builtins.c (fold_builtin_memory_op): Check that expr_size match.
|
||||
* explow.c (expr_size, int_expr_size): Assert that size is non_NULL.
|
||||
|
||||
2006-12-04 Daniel Berlin <dberlin@dberlin.org>
|
||||
|
||||
* tree-ssa-alias.c (compute_may_aliases):
|
||||
|
@ -8202,8 +8202,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
|
||||
|| !TYPE_SIZE_UNIT (desttype)
|
||||
|| TREE_CODE (TYPE_SIZE_UNIT (srctype)) != INTEGER_CST
|
||||
|| TREE_CODE (TYPE_SIZE_UNIT (desttype)) != INTEGER_CST
|
||||
|| !operand_equal_p (TYPE_SIZE_UNIT (srctype), len, 0)
|
||||
|| !operand_equal_p (TYPE_SIZE_UNIT (desttype), len, 0))
|
||||
|| !tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len)
|
||||
|| !tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len))
|
||||
return 0;
|
||||
|
||||
if (get_pointer_alignment (dest, BIGGEST_ALIGNMENT)
|
||||
@ -8218,6 +8218,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
|
||||
srcvar = build_fold_indirect_ref (src);
|
||||
if (TREE_THIS_VOLATILE (srcvar))
|
||||
return 0;
|
||||
if (!tree_int_cst_equal (lang_hooks.expr_size (srcvar), len))
|
||||
return 0;
|
||||
/* With memcpy, it is possible to bypass aliasing rules, so without
|
||||
this check i. e. execute/20060930-2.c would be misoptimized, because
|
||||
it use conflicting alias set to hold argument for the memcpy call.
|
||||
@ -8233,6 +8235,8 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp)
|
||||
destvar = build_fold_indirect_ref (dest);
|
||||
if (TREE_THIS_VOLATILE (destvar))
|
||||
return 0;
|
||||
if (!tree_int_cst_equal (lang_hooks.expr_size (destvar), len))
|
||||
return 0;
|
||||
if (!var_decl_component_p (destvar))
|
||||
return 0;
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2006-12-04 Jan Hubicka <jh@suse.cz>
|
||||
|
||||
* cp-objcp-common.c (cp_expr_size): Return NULL in the case
|
||||
size is undefined.
|
||||
|
||||
2006-12-04 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/29733
|
||||
|
@ -82,29 +82,29 @@ cp_expr_size (tree exp)
|
||||
/* The backend should not be interested in the size of an expression
|
||||
of a type with both of these set; all copies of such types must go
|
||||
through a constructor or assignment op. */
|
||||
gcc_assert (!TYPE_HAS_COMPLEX_INIT_REF (type)
|
||||
|| !TYPE_HAS_COMPLEX_ASSIGN_REF (type)
|
||||
/* But storing a CONSTRUCTOR isn't a copy. */
|
||||
|| TREE_CODE (exp) == CONSTRUCTOR
|
||||
/* And, the gimplifier will sometimes make a copy of
|
||||
an aggregate. In particular, for a case like:
|
||||
if (!TYPE_HAS_COMPLEX_INIT_REF (type)
|
||||
|| !TYPE_HAS_COMPLEX_ASSIGN_REF (type)
|
||||
/* But storing a CONSTRUCTOR isn't a copy. */
|
||||
|| TREE_CODE (exp) == CONSTRUCTOR
|
||||
/* And, the gimplifier will sometimes make a copy of
|
||||
an aggregate. In particular, for a case like:
|
||||
|
||||
struct S { S(); };
|
||||
struct X { int a; S s; };
|
||||
X x = { 0 };
|
||||
struct S { S(); };
|
||||
struct X { int a; S s; };
|
||||
X x = { 0 };
|
||||
|
||||
the gimplifier will create a temporary with
|
||||
static storage duration, perform static
|
||||
initialization of the temporary, and then copy
|
||||
the result. Since the "s" subobject is never
|
||||
constructed, this is a valid transformation. */
|
||||
|| CP_AGGREGATE_TYPE_P (type));
|
||||
|
||||
/* This would be wrong for a type with virtual bases, but they are
|
||||
caught by the assert above. */
|
||||
return (is_empty_class (type)
|
||||
? size_zero_node
|
||||
: CLASSTYPE_SIZE_UNIT (type));
|
||||
the gimplifier will create a temporary with
|
||||
static storage duration, perform static
|
||||
initialization of the temporary, and then copy
|
||||
the result. Since the "s" subobject is never
|
||||
constructed, this is a valid transformation. */
|
||||
|| CP_AGGREGATE_TYPE_P (type))
|
||||
/* This would be wrong for a type with virtual bases. */
|
||||
return (is_empty_class (type)
|
||||
? size_zero_node
|
||||
: CLASSTYPE_SIZE_UNIT (type));
|
||||
else
|
||||
return NULL_TREE;
|
||||
}
|
||||
else
|
||||
/* Use the default code. */
|
||||
|
11
gcc/explow.c
11
gcc/explow.c
@ -245,7 +245,11 @@ expr_size (tree exp)
|
||||
if (TREE_CODE (exp) == WITH_SIZE_EXPR)
|
||||
size = TREE_OPERAND (exp, 1);
|
||||
else
|
||||
size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (lang_hooks.expr_size (exp), exp);
|
||||
{
|
||||
size = lang_hooks.expr_size (exp);
|
||||
gcc_assert (size);
|
||||
size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp);
|
||||
}
|
||||
|
||||
return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
|
||||
}
|
||||
@ -261,7 +265,10 @@ int_expr_size (tree exp)
|
||||
if (TREE_CODE (exp) == WITH_SIZE_EXPR)
|
||||
size = TREE_OPERAND (exp, 1);
|
||||
else
|
||||
size = lang_hooks.expr_size (exp);
|
||||
{
|
||||
size = lang_hooks.expr_size (exp);
|
||||
gcc_assert (size);
|
||||
}
|
||||
|
||||
if (size == 0 || !host_integerp (size, 0))
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user