]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/32140 (Miscompilation with -O1)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Wed, 20 Jun 2007 14:57:10 +0000 (14:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Jun 2007 14:57:10 +0000 (14:57 +0000)
2007-06-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>
Richard Guenther  <rguenther@suse.de>

PR fortran/32140
* trans.c (gfc_build_addr_expr): Use the correct types.

* gfortran.fortran-torture/execute/pr32140.f90: New testcase.

Co-Authored-By: Richard Guenther <rguenther@suse.de>
From-SVN: r125886

gcc/fortran/ChangeLog
gcc/fortran/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/pr32140.f90 [new file with mode: 0644]

index ceb9df53400daa93fb8a9f5fbc773e6e0989f571..fbda11c53402458fc71bb058eed517d4e228dfb8 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/32140
+       * trans.c (gfc_build_addr_expr): Use the correct types.
+
 2007-06-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/20863
index 97336b68f6133d027d57db46267dc7b5ee317b35..81cd12e21cdefc8548ffab635fb1313a680bd5ff 100644 (file)
@@ -266,7 +266,15 @@ gfc_build_addr_expr (tree type, tree t)
       && TREE_CODE (base_type) == ARRAY_TYPE
       && TYPE_MAIN_VARIANT (TREE_TYPE (type))
         == TYPE_MAIN_VARIANT (TREE_TYPE (base_type)))
-    natural_type = type;
+    {
+      tree min_val = size_zero_node;
+      tree type_domain = TYPE_DOMAIN (base_type);
+      if (type_domain && TYPE_MIN_VALUE (type_domain))
+        min_val = TYPE_MIN_VALUE (type_domain);
+      t = build4 (ARRAY_REF, TREE_TYPE (type), t, min_val,
+                 NULL_TREE, NULL_TREE);
+      natural_type = type;
+    }
   else
     natural_type = build_pointer_type (base_type);
 
index ed7e9cc50aef128100c9b2d4c8832f9aa815343c..716b764d93d9b0692330951747a81d50408d5534 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/32140
+       * gfortran.fortran-torture/execute/pr32140.f90: New testcase.
+
 2007-06-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/31959
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/pr32140.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/pr32140.f90
new file mode 100644 (file)
index 0000000..a756e27
--- /dev/null
@@ -0,0 +1,16 @@
+MODULE TEST
+CONTAINS
+PURE FUNCTION s2a_3(s1,s2,s3) RESULT(a)
+    CHARACTER(LEN=*), INTENT(IN)             :: s1, s2, s3
+    CHARACTER(LEN=4), DIMENSION(3)        :: a
+
+  a(1)=s1; a(2)=s2; a(3)=s3
+END FUNCTION
+END MODULE
+
+USE TEST
+character(len=12) :: line
+write(line,'(3A4)') s2a_3("a","bb","ccc")
+IF (line.NE."a   bb  ccc") CALL ABORT()
+END
+