]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp-objcp-common.c (cp_expr_size): Return NULL in the case size is undefined.
authorJan Hubicka <jh@suse.cz>
Mon, 4 Dec 2006 22:51:42 +0000 (23:51 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 4 Dec 2006 22:51:42 +0000 (22:51 +0000)
* 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

gcc/ChangeLog
gcc/builtins.c
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/explow.c

index 3fbc38ae7b70e2b6fc33bed41b5184b3b9830f37..1de07b1f9c449fb02421557142b1bc0d5788b74c 100644 (file)
@@ -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):
index 80c5e1f6d088d64488f200aa4db387d4e10ea19f..0cfdb9af12cad61fb7438efd5eb345d0806197e8 100644 (file)
@@ -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;
 
index f0f93c0e40c4d791fed38303be6216578d6e59da..31c87e20af88c7cf0a15895657f62fc3bbf7cd64 100644 (file)
@@ -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
index a3e19db244fc4b3d7e39364b3c1c54b55571c430..a3640876c1d0bbec70850767d45debdb9e33b695 100644 (file)
@@ -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:
-
-                       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));
+      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 };
+
+            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.  */
index e21e9c112ecbc36233759dcf404974d6fc754e61..a71027447101c7d6d27436c95d99fad55f91a2e5 100644 (file)
@@ -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;