fold-const.c (round_up_loc): Cast divisor to HOST_WIDE_INT before negating it.
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 3 Mar 2015 17:56:07 +0000 (17:56 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 3 Mar 2015 17:56:07 +0000 (17:56 +0000)
* fold-const.c (round_up_loc): Cast divisor to HOST_WIDE_INT before
negating it.

* tree-sra.c (pa_sra_preliminary_function_checks): Fix typo in message.

From-SVN: r221159

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/object_overflow5.adb [new file with mode: 0644]
gcc/tree-sra.c

index 5c1bb2701934e059503a9db5ca41b3db6c63a1d7..a562ee79d180849090c898d08d05400a794eed48 100644 (file)
@@ -1,3 +1,10 @@
+2015-03-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * fold-const.c (round_up_loc): Cast divisor to HOST_WIDE_INT before
+       negating it.
+
+       * tree-sra.c (pa_sra_preliminary_function_checks): Fix typo in message.
+
 2015-03-03  Max Filippov  <jcmvbkbc@gmail.com>
 
        Implement call0 ABI for xtensa
index 83771207c49bc919eb3e040f54b3b940736e00ac..f9f7f26fd35aba68f8f4f05ad50cbf6e743f5716 100644 (file)
@@ -16032,7 +16032,7 @@ round_up_loc (location_t loc, tree value, unsigned int divisor)
 
          t = build_int_cst (TREE_TYPE (value), divisor - 1);
          value = size_binop_loc (loc, PLUS_EXPR, value, t);
-         t = build_int_cst (TREE_TYPE (value), -divisor);
+         t = build_int_cst (TREE_TYPE (value), - (HOST_WIDE_INT) divisor);
          value = size_binop_loc (loc, BIT_AND_EXPR, value, t);
        }
     }
index d1eaddb7e029bea6e2c9841b398bc91f62eb1ed2..d38eb5227681304866df8a3f273472f9a1947488 100644 (file)
@@ -1,3 +1,7 @@
+2015-03-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/object_overflow5.adb: New test.
+
 2015-03-03  Martin Liska  <mliska@suse.cz>
 
        PR ipa/65287
diff --git a/gcc/testsuite/gnat.dg/object_overflow5.adb b/gcc/testsuite/gnat.dg/object_overflow5.adb
new file mode 100644 (file)
index 0000000..4a4f6cf
--- /dev/null
@@ -0,0 +1,20 @@
+-- { dg-do compile }
+
+procedure Object_Overflow5 is
+
+  procedure Proc (c : Character) is begin null; end;
+
+  type Index is new Long_Integer range 0 .. Long_Integer'Last;
+
+  type Arr is array(Index range <>) of Character;
+
+  type Rec (Size: Index := 6) is record -- { dg-warning "Storage_Error" }
+    A: Arr (0..Size);
+  end record;
+
+  Obj : Rec; -- { dg-warning "Storage_Error" }
+
+begin
+  Obj.A(1) := 'a';
+  Proc (Obj.A(1));
+end;
index a6cddafe44bf8a2c4411c1fa102583afb230fa8d..0aed4d29c894ea493ccc71793640db2988536425 100644 (file)
@@ -5144,7 +5144,7 @@ ipa_sra_preliminary_function_checks (struct cgraph_node *node)
     {
       if (dump_file)
        fprintf (dump_file,
-                "A function call has an argument with non-unit alignemnt.\n");
+                "A function call has an argument with non-unit alignment.\n");
       return false;
     }