From patchwork Tue Aug 2 19:58:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kraft X-Patchwork-Id: 107989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E80B7B71CC for ; Wed, 3 Aug 2011 05:54:24 +1000 (EST) Received: (qmail 17005 invoked by alias); 2 Aug 2011 19:54:23 -0000 Received: (qmail 16992 invoked by uid 22791); 2 Aug 2011 19:54:22 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from tatiana.utanet.at (HELO tatiana.utanet.at) (213.90.36.46) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Aug 2011 19:54:03 +0000 Received: from pam.xoc.tele2net.at ([213.90.36.6]) by tatiana.utanet.at with esmtp (Exim 4.76) (envelope-from ) id 1QoL2P-00066H-2v; Tue, 02 Aug 2011 21:54:01 +0200 Received: from d86-33-51-119.cust.tele2.at ([86.33.51.119] helo=[192.168.2.18]) by pam.xoc.tele2net.at with esmtpa (Exim 4.76) (envelope-from ) id 1QoL2O-0008UV-S0; Tue, 02 Aug 2011 21:54:01 +0200 Message-ID: <4E3856F4.8090209@domob.eu> Date: Tue, 02 Aug 2011 21:58:44 +0200 From: Daniel Kraft User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Fortran List , gcc-patches Subject: [Patch, Fortran] PR fortran/49885: Fix automatic character array allocation OpenPGP: id=A3B53998 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, after a loooong while, here's another patch from me. It is a one-line fix for PR 49885, which was introduced by me last year. While the patch should be simple, it wasn't that easy to find the fix (for me at least) ... but I think it should be fairly easy to see now. For some kind of analysis, you can look at my comments in the PR. No regressions on x86_64-unknown-linux-gnu. Ok for trunk? Yours, Daniel - -- OpenPGP: 3BA2 3DDB 7758 F010 BDAB 0DCF 527E 79BA A3B5 3998 or use https://safesend.domob.eu/ - -- Done: Arc-Bar-Cav-Kni-Ran-Rog-Sam-Tou-Val-Wiz To go: Hea-Mon-Pri -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOOFbzAAoJEFJ+ebqjtTmYL/0P/2cEE8FmVSYsBLxK6sy4129X UPbcA8aaKDFjIONrFz98nPZcrw6ph/AYe7mOsQ+K+wx2gsPXHV7L1tx77MAb4Snv M262pfm5I+y9xup3QYy85y4+7N9o2eqmNiV519ogEugtYzZncfMFOeohG2IiQVBr F9uvc9NS4wT6pyUVhilYN/s6C9LmVQw7U003NjD6yK01e7RBWLTY4eUKtpruehMM OIZLVC1iIfyeDNzjAzIwzwvQd2IeINS5iIJCRblYEPrbPYyoWfZ3tUACzddV3Axc 7fIAd247NxQA6s6Vjqa0iMRc2ObCRmxhKfyt1Q3IN3PMAFs80p5BZ0aMEw1CJpNj fU4j9kpiyNd0onJ/3Z8RqFGAuXI1qW1AyitY9KBVLGH9XI7FG7uUR02qnSD1z15Z X2DwW8obD8xxDskbPWGohgUV8vFVQHGNatThgnDBOUquL4ZHvTaWiYPRiAcgq+1F RUZMWQm6rcCR9GkrfDytcq7lupkNN/0QROmmRUtBlkH4/QV52YaIa6YeiX8L6Ebk o1sAm+rn9oldEBySykaKAVT2Sbhfz+IKp6rbE7Js1mIoNmbtFDpQA1AE0APNZvrh JHgWLqxtbqMmMQ08YNk/mUXoXRboK1FoPLKiw3fWhKHEldlJHjeW8RrkBPFOzjAX 0UyNefZsrE0ziuWOAEvE =hjnD -----END PGP SIGNATURE----- 2011-08-02 Daniel Kraft PR fortran/49885 * trans-array.c (gfc_trans_auto_array_allocation): Change gfc_start_block to gfc_init_block to avoid spurious extra-scope. 2011-08-02 Daniel Kraft PR fortran/49885 * gfortran.dg/auto_char_dummy_array_3.f90: New test. Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (revision 176950) +++ gcc/fortran/trans-array.c (working copy) @@ -4882,7 +4882,7 @@ gcc_assert (GFC_ARRAY_TYPE_P (type)); onstack = TREE_CODE (type) != POINTER_TYPE; - gfc_start_block (&init); + gfc_init_block (&init); /* Evaluate character string length. */ if (sym->ts.type == BT_CHARACTER Index: gcc/testsuite/gfortran.dg/auto_char_dummy_array_3.f90 =================================================================== --- gcc/testsuite/gfortran.dg/auto_char_dummy_array_3.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/auto_char_dummy_array_3.f90 (revision 0) @@ -0,0 +1,25 @@ +! { dg-do run } + +! PR fortran/49885 +! Check that character arrays with non-constant char-length are handled +! correctly. + +! Contributed by Daniel Kraft , +! based on original test case and variant by Tobias Burnus in comment 2. + +PROGRAM main + IMPLICIT NONE + + CALL s (10) + +CONTAINS + + SUBROUTINE s (nb) + INTEGER :: nb + CHARACTER(MAX (80, nb)) :: bad_rec(1) + + bad_rec(1)(1:2) = 'abc' + IF (bad_rec(1)(1:2) /= 'ab') CALL abort () + END SUBROUTINE s + +END PROGRAM main