gfortran.h: Add flag_backslash compile-time option.
authorFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 20 Jun 2005 20:14:20 +0000 (20:14 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 20 Jun 2005 20:14:20 +0000 (20:14 +0000)
* gfortran.h: Add flag_backslash compile-time option.
* lang.opt: Add support for -fbackslash option.
* options.c: Likewise.
* primary.c: Implement behavior for -fno-backslash.
* invoke.texi: Add doc for -fbackslash option.
* gfortran.texi: Remove mention of -fno-backslash as a
possible extension.
* gfortran.dg/backslash_1.f90: New test.
* gfortran.dg/backslash_2.f90: New test.

From-SVN: r101216

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/gfortran.texi
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/backslash_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/backslash_2.f90 [new file with mode: 0644]

index da57e97dfc92d690ab3cce97f87e7a7da5d0a558..614a23803d99d02b97b67875fa4486469e6edb4b 100644 (file)
@@ -1,4 +1,14 @@
-2005-06-20  Steven G. Kargl  <kargls@comcast.net.
+2005-06-19  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       * gfortran.h: Add flag_backslash compile-time option.
+       * lang.opt: Add support for -fbackslash option.
+       * options.c: Likewise.
+       * primary.c: Implement behavior for -fno-backslash.
+       * invoke.texi: Add doc for -fbackslash option.
+       * gfortran.texi: Remove mention of -fno-backslash as a
+       possible extension.
+
+2005-06-20  Steven G. Kargl  <kargls@comcast.net>
        (port from g95)
 
        PR fortran/21257
index 69a56e188ac6e0a9f49c7767aa28f4a27096a642..085e1ae72e61c6ef4666ae4b1ed937bf533ca663 100644 (file)
@@ -1421,6 +1421,7 @@ typedef struct
   int flag_pack_derived;
   int flag_repack_arrays;
   int flag_f2c;
+  int flag_backslash;
 
   int q_kind;
 
index 50b649909850adf8ab043cfedef4909192b74ed7..9ac79b884ea2dd036fe110fba427af0e86c176a0 100644 (file)
@@ -503,10 +503,6 @@ module storage either on stack or heap.
 Flag to cause the compiler to distinguish between upper and lower case
 names.  The Fortran 95 standard does not distinguish them.
 
-@item
-Compile switch for changing the interpretation of a backslash from a
-character to ``C''-style escape characters.
-
 @item
 Compile flag to generate code for array conformance checking (suggest -CC).
 
index e3d2e26848acd5d13f2f97bc9e7e150be264694a..feeacf7e9b614ad95a8037fa8065374c243429fe 100644 (file)
@@ -208,6 +208,15 @@ Do nothing if this is already the default.
 @cindex character set
 Allow @samp{$} as a valid character in a symbol name.
 
+@cindex -fno-backslash option
+@cindex options, -fno-backslash
+@item -fno-backslash
+@cindex backslash
+@cindex escape characters
+@item
+Compile switch to change the interpretation of a backslash from
+``C''-style escape characters to a single backslash character.
+
 @cindex -ffixed-line-length-@var{n} option
 @cindex options, -ffixed-line-length-@var{n}
 @item -ffixed-line-length-@var{n}
index 6798b6d4f14f541f5ece9f66768d3debe314ad54..fd92d15ded827d282578aabd8a3c61347becba53 100644 (file)
@@ -85,6 +85,10 @@ fdollar-ok
 F95
 Allow dollar signs in entity names
 
+fbackslash
+F95
+Specify that backslash in string introduces an escape character
+
 fdump-parse-tree
 F95
 Display the code tree after parsing.
index 347f7068b96031cd14fd3057e36ea2020c1d9911..681dbdacc79afcefa394586fdf95f05c3ec28cf3 100644 (file)
@@ -70,6 +70,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   gfc_option.flag_no_backend = 0;
   gfc_option.flag_pack_derived = 0;
   gfc_option.flag_repack_arrays = 0;
+  gfc_option.flag_backslash = 1;
 
   gfc_option.q_kind = gfc_default_double_kind;
 
@@ -233,6 +234,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.flag_dollar_ok = value;
       break;
 
+    case OPT_fbackslash:
+      gfc_option.flag_backslash = value;
+      break;
+
     case OPT_fdump_parse_tree:
       gfc_option.verbose = value;
       break;
index e1acfbf36215656ad2e7e3c8d08d40b1ca93cefc..984adcfa426ef16b1243605162b0ac9a731c3a8b 100644 (file)
@@ -637,7 +637,7 @@ next_string_char (char delimiter)
   if (c == '\n')
     return -2;
 
-  if (c == '\\')
+  if (gfc_option.flag_backslash && c == '\\')
     {
       old_locus = gfc_current_locus;
 
index 18935f588c7735a4b7c11f6746c048b27c653a1f..088e10aeb4fc54b6bce41b2961aff46b82b7b13b 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-19  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       * gfortran.dg/backslash_1.f90: New test.
+       * gfortran.dg/backslash_2.f90: New test.
+
 2005-06-20  Steven G. Kargl  <kargls@comcast.net>
 
        * gfortran.dg/duplicate_labels.f90: New test.
@@ -25,8 +30,8 @@
 
 2005-06-19  Aldy Hernandez  <aldyh@redhat.com>
 
-        PR c++/22115
-        * g++.dg/conversion/simd2.C: Change expected error message.
+       PR c++/22115
+       * g++.dg/conversion/simd2.C: Change expected error message.
 
 2005-06-18  Dorit Nuzman  <dorit@il.ibm.com>
 
diff --git a/gcc/testsuite/gfortran.dg/backslash_1.f90 b/gcc/testsuite/gfortran.dg/backslash_1.f90
new file mode 100644 (file)
index 0000000..db7ddbc
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do run }
+! { dg-options "-fno-backslash" }
+      character(len=4) a
+      open (10, status='scratch')
+      write (10,'(A)') '1\n2'
+      rewind (10)
+      read (10,'(A)') a
+      if (a /= '1\n2') call abort
+      end
diff --git a/gcc/testsuite/gfortran.dg/backslash_2.f90 b/gcc/testsuite/gfortran.dg/backslash_2.f90
new file mode 100644 (file)
index 0000000..2f954d5
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do run }
+! { dg-options "-fbackslash" }
+      integer :: i, e
+      open (10, status='scratch')
+      write (10,'(A)') '1\n2'
+      rewind (10)
+      read (10,*,iostat=e) i
+      if (e /= 0 .or. i /= 1) call abort
+      read (10,*,iostat=e) i
+      if (e /= 0 .or. i /= 2) call abort
+      end