diff mbox

[Fortran] PR fortran/49885: Fix automatic character array allocation

Message ID 4E3856F4.8090209@domob.eu
State New
Headers show

Commit Message

Daniel Kraft Aug. 2, 2011, 7:58 p.m. UTC
-----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  <d@domob.eu>

	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  <d@domob.eu>

	PR fortran/49885
	* gfortran.dg/auto_char_dummy_array_3.f90: New test.

Comments

Tobias Burnus Aug. 2, 2011, 8:04 p.m. UTC | #1
Daniel Kraft wrote:
> 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.

Seemingly, I guessed correctly how the fix had to look like (comment 3). 
Though, the real work is to spot the right place where it goes wrong. 
Thanks got tracing this down and fixing it!

> No regressions on x86_64-unknown-linux-gnu.  Ok for trunk?

OK for the trunk and for 4.6 (as it is a regression).

Tobias

PS: Do you plan to do now some more gfortran work? Or do you completely 
lack the time?
Daniel Kraft Aug. 2, 2011, 8:17 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/02/11 22:04, Tobias Burnus wrote:
> Daniel Kraft wrote:
>> 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.
> 
> Seemingly, I guessed correctly how the fix had to look like (comment
> 3). Though, the real work is to spot the right place where it goes
> wrong. Thanks got tracing this down and fixing it!

Ah, yes!  I must have overlooked that comment completely ... maybe it
would have saved me some time.  But anyway, I found the correct fix. ;)

>> No regressions on x86_64-unknown-linux-gnu.  Ok for trunk?
> 
> OK for the trunk and for 4.6 (as it is a regression).

Thanks for the review.  Committed as rev. 177211 on trunk, I will
backport it to 4.6.  Can I do so tomorrow or should I rather wait for a
week?

> PS: Do you plan to do now some more gfortran work? Or do you
> completely lack the time?

Hm, good question.  I hope that I will have at least some time over the
coming two months, but I can't really promise.  I still have some exams
to do and also other work.  So probably only small fixes, unfortunately.
 But I'll try to do at least those occasionally.

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/

iQIcBAEBAgAGBQJOOFtMAAoJEFJ+ebqjtTmYDP8P/ja55A5fdHkXVaWXZijXRH1u
QHlAbqZf/JKpH2qefGP1gtfPDh7glDh/Scsv42a1KezBLT2dILY8iVp8FsadNiLx
fNhZtCozDrlhYhGvBy2IoN4+lgnW6zkPaWSvrBJVCOme0mP8h9bNje5tGo9RjLJv
E7Oi4NJaJfae9leP9CkSf5u13qV0DwPDp4NwLGXRqYKtgrXX0KbhoWqBZnWwHJfS
vJyerg6ps/pOCnSEqxP9cTs1GHvGEqUTVVBwNJnY0K8LwewnWXunyFH7sWZAQaou
DkDnxns6Opj9yRX3QMeas1Gdud+mBVlovfzzcRMyKrxNfemlgyeCK1E3udDN6Fgx
nTseuV4tljA2eLA2XzPwEQd4Cd6bm1ch16XAz5eTkSc6JCuSBqTvs4+W/I6W1Lxd
M+rZvmBrLFIdff4BWESEIXVSW0uNhltn/nr7/actPPHlyHEhfPK2I6sDR9KyMric
FfXOp1RJQEKfYCH7Y4wqcxGkkXPqGZVJdeylSgaOw8WpcSULpVylpZ5nd5tx1a9H
OkIMK/ORVmxNeS4XHsxVCYjz7IYc8WIlmFj9q838R9jf3ozKp5DqWVOAylN3+EQd
iXI/t/fcMeooIp0HuBeWwI3IQHlJapJumqEo8zVMgBvWsEwfWB0Tj7uWMrNlmUx/
PaMRvRHXu8nfMauGXYu0
=dvk6
-----END PGP SIGNATURE-----
Daniel Kraft Aug. 3, 2011, 9:42 a.m. UTC | #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/02/11 22:04, Tobias Burnus wrote:
> Daniel Kraft wrote:
>> No regressions on x86_64-unknown-linux-gnu.  Ok for trunk?
> 
> OK for the trunk and for 4.6 (as it is a regression).

And committed on 4.6 branch as rev. 177249, there also were no
regressions on x86_64-unknown-linux-gnu.

I'll close the PR now.

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/

iQIcBAEBAgAGBQJOORgiAAoJEFJ+ebqjtTmYYAsP/i2U3SaqOMAQe75hg6/e4GaN
6Fq2svUk7wN5ooMN+01zNYKi1igeqOKGyLpEycMJAseZ8bYn6C2KtXWuJdNN+JGl
u2e95FkrkHSwO6a3jGYBSFXeor3/fUsk8TPKEyk12Be61C4p6mlgnCyNj6OadSZs
Okujz3VCFj0FEtoD2FO+JAOtHMuDY/PW8sZR0M8hlJzGme2INpEf5J57/hSQk7EP
X7TSMiy1/i9cmAHS91VGN8PTcRQo6y3vI+PN2ymZ8EAY0WPNeyUQO4Q5NDV9XP1T
yRi6NDGWLDjOReXy0ne80NrZWCUQi8ihMPqa/QXDlsF5h60hkHMqwfXX9rvxw6Kc
jLELEGqP3kTgBZuBfN3wCZwd8FSakc1vBBgfKkOEel3xw1DCa+9fp0Bz+CO9Zc3E
vbLns2GHvJg+hVu495BZlgC16MhbxzJLM4uTMoL4NsR+vazS71w4fSlh2lWvQrQr
CdMILamqsm4MZmc5z6SH7zD2aMWCVt/k7isSfj7kAtvYdXg0xnIxDPBgI28c7oTm
OU/o53es91Y3cj4ISilqooZIEwUKvt+cRJF851j0ZfsVp3iDFlatraHCQGYTM/5s
EyboGV7mpos4BOxx2V5XroviHR2D6t4NRVoZnBgpQUEeAH82oAGAMiQGVMOsYpH4
MIaKxOcSL0G/JVhQb1uF
=FK7V
-----END PGP SIGNATURE-----
diff mbox

Patch

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 <d@domob.eu>,
+! 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