aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2014-07-25 21:09:56 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2014-07-25 21:09:56 +0200
commita634323ae02c99a5a7e2b7c9674109ed2af6c969 (patch)
tree73b2d7327321db66dbd5ae0f98398576f7b65ee3 /gcc
parenta4b0388b2453efd5d9cb4caf38608e7be4d8e007 (diff)
downloadgcc-a634323ae02c99a5a7e2b7c9674109ed2af6c969.zip
gcc-a634323ae02c99a5a7e2b7c9674109ed2af6c969.tar.gz
gcc-a634323ae02c99a5a7e2b7c9674109ed2af6c969.tar.bz2
simplify.c (gfc_simplify_storage_size): Use proper integer kind for the returned value.
2014-07-25 Tobias Burnus <burnus@net-b.de> * simplify.c (gfc_simplify_storage_size): Use proper integer kind for the returned value. 2014-07-25 Tobias Burnus <burnus@net-b.de> * gfortran.dg/storage_size_5.f90: New. From-SVN: r213060
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/simplify.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gfortran.dg/storage_size_5.f9044
4 files changed, 54 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e953698..8071e11 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2014-07-25 Tobias Burnus <burnus@net-b.de>
+
+ * simplify.c (gfc_simplify_storage_size): Use proper
+ integer kind for the returned value.
+
2014-07-24 Uros Bizjak <ubizjak@gmail.com>
* intrinsic.texi (Intrinsic Procedures) <ATOMIC_DEFINE>: Move to
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 60d8593..d4a67ad 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -5841,11 +5841,9 @@ gfc_simplify_storage_size (gfc_expr *x,
if (k == -1)
return &gfc_bad_expr;
- result = gfc_get_constant_expr (BT_INTEGER, gfc_index_integer_kind,
- &x->where);
+ result = gfc_get_constant_expr (BT_INTEGER, k, &x->where);
mpz_set_si (result->value.integer, gfc_element_size (x));
-
mpz_mul_ui (result->value.integer, result->value.integer, BITS_PER_UNIT);
return range_check (result, "STORAGE_SIZE");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 72ba8a7..ebf7bad 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-07-25 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.dg/storage_size_5.f90: New.
+
2014-07-25 Richard Biener <rguenther@suse.de>
PR middle-end/61762
diff --git a/gcc/testsuite/gfortran.dg/storage_size_5.f90 b/gcc/testsuite/gfortran.dg/storage_size_5.f90
new file mode 100644
index 0000000..ae0f126
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/storage_size_5.f90
@@ -0,0 +1,44 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+subroutine test()
+ implicit none
+ integer :: i0, i1, i2, i3, i4
+ i0 = kind(STORAGE_SIZE(5))
+ i1 = kind(STORAGE_SIZE(5, kind=1))
+ i2 = kind(STORAGE_SIZE(5, kind=2))
+ i3 = kind(STORAGE_SIZE(5, kind=4))
+ i4 = kind(STORAGE_SIZE(5, kind=8))
+end subroutine test
+
+subroutine test2(x)
+ implicit none
+ class(*) :: x
+ integer :: j0, j1, j2, j3, j4
+ integer(1) :: k1
+ integer(2) :: k2
+ j0 = kind(STORAGE_SIZE(x))
+ j1 = kind(STORAGE_SIZE(x, kind=1))
+ j2 = kind(STORAGE_SIZE(x, kind=2))
+ j3 = kind(STORAGE_SIZE(x, kind=4))
+ j4 = kind(STORAGE_SIZE(x, kind=8))
+
+ k1 = STORAGE_SIZE(x, kind=1)
+ k2 = STORAGE_SIZE(x, kind=2)
+end subroutine test2
+
+! { dg-final { scan-tree-dump-times "i0 = 4;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "i1 = 1;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "i2 = 2;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "i3 = 4;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "i4 = 8;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "j0 = 4;" 1 "original" } }
+
+! { dg-final { scan-tree-dump-times "j1 = 1;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "j2 = 2;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "j3 = 4;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "j4 = 8;" 1 "original" } }
+
+! { dg-final { scan-tree-dump-times "k1 = \\(integer\\(kind=1\\)\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "k2 = \\(integer\\(kind=2\\)\\)" 1 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }