[fortran,committed] Fix unescaping of included files

FX fxcoudert@gmail.com
Wed May 14 14:23:00 GMT 2008


My recent wide characters patch (the first one, dealing with memory
representation of source files) introduced a bug in the unescaping of
included filenames, because I allocated too little memory for a wide
string. This turned out to break bootstrap on mingw, and is fixed by
the patch below, which I committed as obvious. I also added a
preprocessed testcase to prevent this to happen again.

FX


2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR fortran/36215
        * scanner.c (preprocessor_line): Allocate enough memory for a
        wide string.

2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR fortran/36215
        * gfortran.dg/include_3.f95: New test.



Index: fortran/scanner.c
===================================================================
--- fortran/scanner.c   (revision 135088)
+++ fortran/scanner.c   (working copy)
@@ -1570,7 +1570,7 @@ preprocessor_line (gfc_char_t *c)
   if (unescape)
     {
       gfc_char_t *s = wide_filename;
-      gfc_char_t *d = gfc_getmem (c - wide_filename - unescape);
+      gfc_char_t *d = gfc_get_wide_string (c - wide_filename - unescape);

       wide_filename = d;
       while (*s)
Index: testsuite/gfortran.dg/include_3.f95
===================================================================
--- testsuite/gfortran.dg/include_3.f95 (revision 0)
+++ testsuite/gfortran.dg/include_3.f95 (revision 0)
@@ -0,0 +1,26 @@
+# 1 "../../../trunk/libgfortran/generated/_abs_c4.F90"
+# 1 "C:\\msys\\1.0.10\\home\\FX\\ibin\\i586-pc-mingw32\\libgfortran//"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "../../../trunk/libgfortran/generated/_abs_c4.F90"
+!   Comment here
+
+# 1 "./config.h" 1
+
+# 37 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+# 1 "./kinds.inc" 1
+# 38 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+# 1 "./c99_protos.inc" 1
+# 39 "../../../trunk/libgfortran/generated/_abs_c4.F90" 2
+
+elemental function abs_c4 (parm)
+   complex (kind=4), intent (in) :: parm
+   real (kind=4) :: abs_c4
+
+   abs_c4 = abs (parm)
+end function
+
+! { dg-do compile }
+! { dg-options "-fpreprocessed -g3" }




-- 
FX Coudert
http://www.homepages.ucl.ac.uk/~uccafco/



More information about the Fortran mailing list