Blame SOURCES/gcc8-fortran-fdec-include.patch

93e26d
2018-11-21  Jakub Jelinek  <jakub@redhat.com>
93e26d
	    Mark Eggleston  <mark.eggleston@codethink.com>
93e26d
93e26d
	* lang.opt (fdec-include): New option.
93e26d
	* options.c (set_dec_flags): Set also flag_dec_include.
93e26d
	* scanner.c (include_line): Change return type from bool to int.
93e26d
	In fixed form allow spaces in between include keyword letters.
93e26d
	For -fdec-include, allow in fixed form 0 in column 6.  With
93e26d
	-fdec-include return -1 if the parsed line is not full include
93e26d
	statement and it could be successfully completed on continuation
93e26d
	lines.
93e26d
	(include_stmt): New function.
93e26d
	(load_file): Adjust include_line caller.  If it returns -1, keep
93e26d
	trying include_stmt until it stops returning -1 whenever adding
93e26d
	further line of input.
93e26d
93e26d
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
93e26d
index 2b7f2903761..fe0c6934220 100644
93e26d
--- a/gcc/fortran/lang.opt
93e26d
+++ b/gcc/fortran/lang.opt
93e26d
@@ -440,6 +440,10 @@ fdec
93e26d
 Fortran Var(flag_dec_pad_with_spaces)
93e26d
 For character to integer conversions, use spaces for the pad rather than NUL.
93e26d
 
93e26d
+fdec-include
93e26d
+Fortran Var(flag_dec_include)
93e26d
+Enable legacy parsing of INCLUDE as statement.
93e26d
+
93e26d
 fdec-intrinsic-ints
93e26d
 Fortran Var(flag_dec_intrinsic_ints)
93e26d
 Enable kind-specific variants of integer intrinsic functions.
93e26d
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
93e26d
index 73f5389361d..e59ba31ba7b 100644
93e26d
--- a/gcc/fortran/options.c
93e26d
+++ b/gcc/fortran/options.c
93e26d
@@ -68,6 +68,7 @@ set_dec_flags (int value)
93e26d
   flag_dec_intrinsic_ints |= value;
93e26d
   flag_dec_static |= value;
93e26d
   flag_dec_math |= value;
93e26d
+  flag_dec_include |= value;
93e26d
 }
93e26d
 
93e26d
 
93e26d
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
93e26d
index 55d6dafdb5d..5b27ab5e52d 100644
93e26d
--- a/gcc/fortran/scanner.c
93e26d
+++ b/gcc/fortran/scanner.c
93e26d
@@ -2135,14 +2135,18 @@ static bool load_file (const char *, const char *, bool);
93e26d
 /* include_line()-- Checks a line buffer to see if it is an include
93e26d
    line.  If so, we call load_file() recursively to load the included
93e26d
    file.  We never return a syntax error because a statement like
93e26d
-   "include = 5" is perfectly legal.  We return false if no include was
93e26d
-   processed or true if we matched an include.  */
93e26d
+   "include = 5" is perfectly legal.  We return 0 if no include was
93e26d
+   processed, 1 if we matched an include or -1 if include was
93e26d
+   partially processed, but will need continuation lines.  */
93e26d
 
93e26d
-static bool
93e26d
+static int
93e26d
 include_line (gfc_char_t *line)
93e26d
 {
93e26d
   gfc_char_t quote, *c, *begin, *stop;
93e26d
   char *filename;
93e26d
+  const char *include = "include";
93e26d
+  bool allow_continuation = flag_dec_include;
93e26d
+  int i;
93e26d
 
93e26d
   c = line;
93e26d
 
93e26d
@@ -2158,42 +2162,133 @@ include_line (gfc_char_t *line)
93e26d
       else
93e26d
 	{
93e26d
 	  if ((*c == '!' || *c == 'c' || *c == 'C' || *c == '*')
93e26d
-	      && c[1] == '$' && (c[2] == ' ' || c[2] == '\t'))
93e26d
+	      && c[1] == '$' && c[2] == ' ')
93e26d
 	    c += 3;
93e26d
 	}
93e26d
     }
93e26d
 
93e26d
-  while (*c == ' ' || *c == '\t')
93e26d
-    c++;
93e26d
+  if (gfc_current_form == FORM_FREE)
93e26d
+    {
93e26d
+      while (*c == ' ' || *c == '\t')
93e26d
+	c++;
93e26d
+      if (gfc_wide_strncasecmp (c, "include", 7))
93e26d
+	{
93e26d
+	  if (!allow_continuation)
93e26d
+	    return 0;
93e26d
+	  for (i = 0; i < 7; ++i)
93e26d
+	    {
93e26d
+	      gfc_char_t c1 = gfc_wide_tolower (*c);
93e26d
+	      if (c1 != (unsigned char) include[i])
93e26d
+		break;
93e26d
+	      c++;
93e26d
+	    }
93e26d
+	  if (i == 0 || *c != '&')
93e26d
+	    return 0;
93e26d
+	  c++;
93e26d
+	  while (*c == ' ' || *c == '\t')
93e26d
+	    c++;
93e26d
+	  if (*c == '\0' || *c == '!')
93e26d
+	    return -1;
93e26d
+	  return 0;
93e26d
+	}
93e26d
 
93e26d
-  if (gfc_wide_strncasecmp (c, "include", 7))
93e26d
-    return false;
93e26d
+      c += 7;
93e26d
+    }
93e26d
+  else
93e26d
+    {
93e26d
+      while (*c == ' ' || *c == '\t')
93e26d
+	c++;
93e26d
+      if (flag_dec_include && *c == '0' && c - line == 5)
93e26d
+	{
93e26d
+	  c++;
93e26d
+	  while (*c == ' ' || *c == '\t')
93e26d
+	    c++;
93e26d
+	}
93e26d
+      if (c - line < 6)
93e26d
+	allow_continuation = false;
93e26d
+      for (i = 0; i < 7; ++i)
93e26d
+	{
93e26d
+	  gfc_char_t c1 = gfc_wide_tolower (*c);
93e26d
+	  if (c1 != (unsigned char) include[i])
93e26d
+	    break;
93e26d
+	  c++;
93e26d
+	  while (*c == ' ' || *c == '\t')
93e26d
+	    c++;
93e26d
+	}
93e26d
+      if (!allow_continuation)
93e26d
+	{
93e26d
+	  if (i != 7)
93e26d
+	    return 0;
93e26d
+	}
93e26d
+      else if (i != 7)
93e26d
+	{
93e26d
+	  if (i == 0)
93e26d
+	    return 0;
93e26d
+
93e26d
+	  /* At the end of line or comment this might be continued.  */
93e26d
+	  if (*c == '\0' || *c == '!')
93e26d
+	    return -1;
93e26d
+
93e26d
+	  return 0;
93e26d
+	}
93e26d
+    }
93e26d
 
93e26d
-  c += 7;
93e26d
   while (*c == ' ' || *c == '\t')
93e26d
     c++;
93e26d
 
93e26d
   /* Find filename between quotes.  */
93e26d
-  
93e26d
+
93e26d
   quote = *c++;
93e26d
   if (quote != '"' && quote != '\'')
93e26d
-    return false;
93e26d
+    {
93e26d
+      if (allow_continuation)
93e26d
+	{
93e26d
+	  if (gfc_current_form == FORM_FREE)
93e26d
+	    {
93e26d
+	      if (quote == '&')
93e26d
+		{
93e26d
+		  while (*c == ' ' || *c == '\t')
93e26d
+		    c++;
93e26d
+		  if (*c == '\0' || *c == '!')
93e26d
+		    return -1;
93e26d
+		}
93e26d
+	    }
93e26d
+	  else if (quote == '\0' || quote == '!')
93e26d
+	    return -1;
93e26d
+	}
93e26d
+      return 0;
93e26d
+    }
93e26d
 
93e26d
   begin = c;
93e26d
 
93e26d
+  bool cont = false;
93e26d
   while (*c != quote && *c != '\0')
93e26d
-    c++;
93e26d
+    {
93e26d
+      if (allow_continuation && gfc_current_form == FORM_FREE)
93e26d
+	{
93e26d
+	  if (*c == '&')
93e26d
+	    cont = true;
93e26d
+	  else if (*c != ' ' && *c != '\t')
93e26d
+	    cont = false;
93e26d
+	}
93e26d
+      c++;
93e26d
+    }
93e26d
 
93e26d
   if (*c == '\0')
93e26d
-    return false;
93e26d
+    {
93e26d
+      if (allow_continuation
93e26d
+	  && (cont || gfc_current_form != FORM_FREE))
93e26d
+	return -1;
93e26d
+      return 0;
93e26d
+    }
93e26d
 
93e26d
   stop = c++;
93e26d
-  
93e26d
+
93e26d
   while (*c == ' ' || *c == '\t')
93e26d
     c++;
93e26d
 
93e26d
   if (*c != '\0' && *c != '!')
93e26d
-    return false;
93e26d
+    return 0;
93e26d
 
93e26d
   /* We have an include line at this point.  */
93e26d
 
93e26d
@@ -2205,9 +2300,130 @@ include_line (gfc_char_t *line)
93e26d
     exit (FATAL_EXIT_CODE);
93e26d
 
93e26d
   free (filename);
93e26d
-  return true;
93e26d
+  return 1;
93e26d
 }
93e26d
 
93e26d
+/* Similarly, but try to parse an INCLUDE statement, using gfc_next_char etc.
93e26d
+   APIs.  Return 1 if recognized as valid INCLUDE statement and load_file has
93e26d
+   been called, 0 if it is not a valid INCLUDE statement and -1 if eof has
93e26d
+   been encountered while parsing it.  */
93e26d
+static int
93e26d
+include_stmt (gfc_linebuf *b)
93e26d
+{
93e26d
+  int ret = 0, i, length;
93e26d
+  const char *include = "include";
93e26d
+  gfc_char_t c, quote = 0;
93e26d
+  locus str_locus;
93e26d
+  char *filename;
93e26d
+
93e26d
+  continue_flag = 0;
93e26d
+  end_flag = 0;
93e26d
+  gcc_attribute_flag = 0;
93e26d
+  openmp_flag = 0;
93e26d
+  openacc_flag = 0;
93e26d
+  continue_count = 0;
93e26d
+  continue_line = 0;
93e26d
+  gfc_current_locus.lb = b;
93e26d
+  gfc_current_locus.nextc = b->line;
93e26d
+
93e26d
+  gfc_skip_comments ();
93e26d
+  gfc_gobble_whitespace ();
93e26d
+
93e26d
+  for (i = 0; i < 7; i++)
93e26d
+    {
93e26d
+      c = gfc_next_char ();
93e26d
+      if (c != (unsigned char) include[i])
93e26d
+	{
93e26d
+	  if (gfc_current_form == FORM_FIXED
93e26d
+	      && i == 0
93e26d
+	      && c == '0'
93e26d
+	      && gfc_current_locus.nextc == b->line + 6)
93e26d
+	    {
93e26d
+	      gfc_gobble_whitespace ();
93e26d
+	      i--;
93e26d
+	      continue;
93e26d
+	    }
93e26d
+	  gcc_assert (i != 0);
93e26d
+	  if (c == '\n')
93e26d
+	    {
93e26d
+	      gfc_advance_line ();
93e26d
+	      gfc_skip_comments ();
93e26d
+	      if (gfc_at_eof ())
93e26d
+		ret = -1;
93e26d
+	    }
93e26d
+	  goto do_ret;
93e26d
+	}
93e26d
+    }
93e26d
+  gfc_gobble_whitespace ();
93e26d
+
93e26d
+  c = gfc_next_char ();
93e26d
+  if (c == '\'' || c == '"')
93e26d
+    quote = c;
93e26d
+  else
93e26d
+    {
93e26d
+      if (c == '\n')
93e26d
+	{
93e26d
+	  gfc_advance_line ();
93e26d
+	  gfc_skip_comments ();
93e26d
+	  if (gfc_at_eof ())
93e26d
+	    ret = -1;
93e26d
+	}
93e26d
+      goto do_ret;
93e26d
+    }
93e26d
+
93e26d
+  str_locus = gfc_current_locus;
93e26d
+  length = 0;
93e26d
+  do
93e26d
+    {
93e26d
+      c = gfc_next_char_literal (INSTRING_NOWARN);
93e26d
+      if (c == quote)
93e26d
+	break;
93e26d
+      if (c == '\n')
93e26d
+	{
93e26d
+	  gfc_advance_line ();
93e26d
+	  gfc_skip_comments ();
93e26d
+	  if (gfc_at_eof ())
93e26d
+	    ret = -1;
93e26d
+	  goto do_ret;
93e26d
+	}
93e26d
+      length++;
93e26d
+    }
93e26d
+  while (1);
93e26d
+
93e26d
+  gfc_gobble_whitespace ();
93e26d
+  c = gfc_next_char ();
93e26d
+  if (c != '\n')
93e26d
+    goto do_ret;
93e26d
+
93e26d
+  gfc_current_locus = str_locus;
93e26d
+  ret = 1;
93e26d
+  filename = XNEWVEC (char, length + 1);
93e26d
+  for (i = 0; i < length; i++)
93e26d
+    {
93e26d
+      c = gfc_next_char_literal (INSTRING_WARN);
93e26d
+      gcc_assert (gfc_wide_fits_in_byte (c));
93e26d
+      filename[i] = (unsigned char) c;
93e26d
+    }
93e26d
+  filename[length] = '\0';
93e26d
+  if (!load_file (filename, NULL, false))
93e26d
+    exit (FATAL_EXIT_CODE);
93e26d
+
93e26d
+  free (filename);
93e26d
+
93e26d
+do_ret:
93e26d
+  continue_flag = 0;
93e26d
+  end_flag = 0;
93e26d
+  gcc_attribute_flag = 0;
93e26d
+  openmp_flag = 0;
93e26d
+  openacc_flag = 0;
93e26d
+  continue_count = 0;
93e26d
+  continue_line = 0;
93e26d
+  memset (&gfc_current_locus, '\0', sizeof (locus));
93e26d
+  memset (&openmp_locus, '\0', sizeof (locus));
93e26d
+  memset (&openacc_locus, '\0', sizeof (locus));
93e26d
+  memset (&gcc_attribute_locus, '\0', sizeof (locus));
93e26d
+  return ret;
93e26d
+}
93e26d
 
93e26d
 /* Load a file into memory by calling load_line until the file ends.  */
93e26d
 
93e26d
@@ -2215,7 +2431,7 @@ static bool
93e26d
 load_file (const char *realfilename, const char *displayedname, bool initial)
93e26d
 {
93e26d
   gfc_char_t *line;
93e26d
-  gfc_linebuf *b;
93e26d
+  gfc_linebuf *b, *include_b = NULL;
93e26d
   gfc_file *f;
93e26d
   FILE *input;
93e26d
   int len, line_len;
93e26d
@@ -2318,6 +2534,7 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
93e26d
   for (;;)
93e26d
     {
93e26d
       int trunc = load_line (input, &line, &line_len, NULL);
93e26d
+      int inc_line;
93e26d
 
93e26d
       len = gfc_wide_strlen (line);
93e26d
       if (feof (input) && len == 0)
93e26d
@@ -2366,11 +2583,12 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
93e26d
 	}
93e26d
 
93e26d
       /* Preprocessed files have preprocessor lines added before the byte
93e26d
-         order mark, so first_line is not about the first line of the file
93e26d
+	 order mark, so first_line is not about the first line of the file
93e26d
 	 but the first line that's not a preprocessor line.  */
93e26d
       first_line = false;
93e26d
 
93e26d
-      if (include_line (line))
93e26d
+      inc_line = include_line (line);
93e26d
+      if (inc_line > 0)
93e26d
 	{
93e26d
 	  current_file->line++;
93e26d
 	  continue;
93e26d
@@ -2403,6 +2621,36 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
93e26d
 
93e26d
       while (file_changes_cur < file_changes_count)
93e26d
 	file_changes[file_changes_cur++].lb = b;
93e26d
+
93e26d
+      if (flag_dec_include)
93e26d
+	{
93e26d
+	  if (include_b && b != include_b)
93e26d
+	    {
93e26d
+	      int inc_line2 = include_stmt (include_b);
93e26d
+	      if (inc_line2 == 0)
93e26d
+		include_b = NULL;
93e26d
+	      else if (inc_line2 > 0)
93e26d
+		{
93e26d
+		  do
93e26d
+		    {
93e26d
+		      if (gfc_current_form == FORM_FIXED)
93e26d
+			{
93e26d
+			  for (gfc_char_t *p = include_b->line; *p; p++)
93e26d
+			    *p = ' ';
93e26d
+			}
93e26d
+		      else
93e26d
+			include_b->line[0] = '\0';
93e26d
+                      if (include_b == b)
93e26d
+			break;
93e26d
+		      include_b = include_b->next;
93e26d
+		    }
93e26d
+		  while (1);
93e26d
+		  include_b = NULL;
93e26d
+		}
93e26d
+	    }
93e26d
+	  if (inc_line == -1 && !include_b)
93e26d
+	    include_b = b;
93e26d
+	}
93e26d
     }
93e26d
 
93e26d
   /* Release the line buffer allocated in load_line.  */
93e26d
diff --git a/gcc/testsuite/gfortran.dg/gomp/include_1.f b/gcc/testsuite/gfortran.dg/gomp/include_1.f
93e26d
new file mode 100644
93e26d
index 00000000000..715eb5b97e3
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/gomp/include_1.f
93e26d
@@ -0,0 +1,49 @@
93e26d
+c { dg-do compile }
93e26d
+c { dg-options "-fopenmp -fdec" }
93e26d
+      subroutine foo
93e26d
+      implicit none
93e26d
+c$   0include 'include_1.inc'
93e26d
+      i = 1
93e26d
+      end subroutine foo
93e26d
+      subroutine bar
93e26d
+      implicit none
93e26d
+      i
93e26d
+C$   ;n
93e26d
+     +c
93e26d
+                 
93e26d
+c   some comment
93e26d
+
93e26d
+*$   ll
93e26d
+C comment line
93e26d
+     uu
93e26d
+     DD
93e26d
+     ee'include_1.inc'
93e26d
+      i = 1
93e26d
+      end subroutine bar
93e26d
+      subroutine baz
93e26d
+      implicit none
93e26d
+     0include
93e26d
+     + 'include_1.inc'
93e26d
+      i = 1
93e26d
+      end subroutine baz
93e26d
+      subroutine qux
93e26d
+      implicit none
93e26d
+!$     i   n   C   lude                                             'inc
93e26d
+* another comment line
93e26d
+     &lude_1.inc'
93e26d
+      i = 1
93e26d
+      end subroutine qux
93e26d
+       subroutine quux
93e26d
+       implicit none
93e26d
+C$   0inc
93e26d
+*$   1lud
93e26d
+c$   2e                                                                '
93e26d
+!$   3include_1.inc'
93e26d
+      i = 1
93e26d
+      end subroutine quux
93e26d
+      program include_12
93e26d
+      implicit none
93e26d
+      include
93e26d
+! comment
93e26d
+c$   +'include_1.inc'
93e26d
+      end program
93e26d
diff --git a/gcc/testsuite/gfortran.dg/gomp/include_1.inc b/gcc/testsuite/gfortran.dg/gomp/include_1.inc
93e26d
new file mode 100644
93e26d
index 00000000000..5dd841c5573
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/gomp/include_1.inc
93e26d
@@ -0,0 +1 @@
93e26d
+      integer i
93e26d
diff --git a/gcc/testsuite/gfortran.dg/gomp/include_2.f90 b/gcc/testsuite/gfortran.dg/gomp/include_2.f90
93e26d
new file mode 100644
93e26d
index 00000000000..9c4ff15afb8
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/gomp/include_2.f90
93e26d
@@ -0,0 +1,32 @@
93e26d
+! { dg-do compile }
93e26d
+! { dg-options "-fopenmp -fdec-include" }
93e26d
+subroutine foo
93e26d
+  implicit none
93e26d
+!$  incl& ! comment1
93e26d
+!$ &u&
93e26d
+!$       &de           &     ! comment2
93e26d
+!$ 'include&
93e26d
+  &_1.inc'
93e26d
+  i = 1
93e26d
+end subroutine foo
93e26d
+subroutine bar
93e26d
+  implicit none
93e26d
+!$ include &
93e26d
+
93e26d
+! comment3
93e26d
+
93e26d
+!$ "include_1.inc"
93e26d
+  i = 1
93e26d
+end subroutine bar
93e26d
+subroutine baz
93e26d
+  implicit none
93e26d
+!$                                  include&
93e26d
+!$ &'include_1.&
93e26d
+!$ &inc'
93e26d
+  i = 1
93e26d
+end subroutine baz
93e26d
+subroutine qux
93e26d
+  implicit none
93e26d
+!$  include '&
93e26d
+include_1.inc'
93e26d
+end subroutine qux
93e26d
diff --git a/gcc/testsuite/gfortran.dg/include_10.f b/gcc/testsuite/gfortran.dg/include_10.f
93e26d
new file mode 100644
93e26d
index 00000000000..7df2a196954
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/include_10.f
93e26d
@@ -0,0 +1,11 @@
93e26d
+c { dg-do compile }
93e26d
+      subroutine foo
93e26d
+      implicit none
93e26d
+      include 'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine foo
93e26d
+      subroutine bar
93e26d
+      implicit none
93e26d
+      i n cl UD e'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine bar
93e26d
diff --git a/gcc/testsuite/gfortran.dg/include_10.inc b/gcc/testsuite/gfortran.dg/include_10.inc
93e26d
new file mode 100644
93e26d
index 00000000000..5dd841c5573
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/include_10.inc
93e26d
@@ -0,0 +1 @@
93e26d
+      integer i
93e26d
diff --git a/gcc/testsuite/gfortran.dg/include_11.f b/gcc/testsuite/gfortran.dg/include_11.f
93e26d
new file mode 100644
93e26d
index 00000000000..0e68a78c236
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/include_11.f
93e26d
@@ -0,0 +1,20 @@
93e26d
+c { dg-do compile }
93e26d
+      subroutine foo
93e26d
+      implicit none
93e26d
+c We used to accept following in fixed mode.  Shall we at least
93e26d
+c warn about it?
93e26d
+include 'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine foo
93e26d
+      subroutine bar
93e26d
+c Likewise here.
93e26d
+      implicit none
93e26d
+  include'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine bar
93e26d
+      subroutine baz
93e26d
+c And here.
93e26d
+      implicit none
93e26d
+     include 'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine baz
93e26d
diff --git a/gcc/testsuite/gfortran.dg/include_12.f b/gcc/testsuite/gfortran.dg/include_12.f
93e26d
new file mode 100644
93e26d
index 00000000000..4b3e3bed075
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/include_12.f
93e26d
@@ -0,0 +1,65 @@
93e26d
+c { dg-do compile }
93e26d
+c { dg-options "-fdec-include" }
93e26d
+      subroutine foo
93e26d
+      implicit none
93e26d
+     0include 'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine foo
93e26d
+      subroutine bar
93e26d
+      implicit none
93e26d
+      i
93e26d
+     ;n
93e26d
+     +c
93e26d
+                 
93e26d
+c   some comment
93e26d
+
93e26d
+     ll
93e26d
+C comment line
93e26d
+     uu
93e26d
+     DD
93e26d
+     ee'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine bar
93e26d
+      subroutine baz
93e26d
+      implicit none
93e26d
+     0include
93e26d
+     + 'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine baz
93e26d
+      subroutine qux
93e26d
+      implicit none
93e26d
+       i   n   C   lude                                             'inc
93e26d
+* another comment line
93e26d
+     &lude_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine qux
93e26d
+       subroutine quux
93e26d
+       implicit none
93e26d
+     0inc
93e26d
+     1lud
93e26d
+     2e                                                                '
93e26d
+     3include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine quux
93e26d
+      program include_12
93e26d
+      implicit none
93e26d
+      include
93e26d
+! comment
93e26d
+     +'include_10.inc'
93e26d
+      end program
93e26d
+      subroutine quuz
93e26d
+      implicit none
93e26d
+      integer include
93e26d
+      include
93e26d
+     +"include_10.inc"
93e26d
+      i = 1
93e26d
+      include
93e26d
+     + = 2
93e26d
+      write (*,*) include
93e26d
+      end subroutine quuz
93e26d
+      subroutine corge
93e26d
+      implicit none
93e26d
+      include
93e26d
+     +'include_10.inc'
93e26d
+      i = 1
93e26d
+      end subroutine corge
93e26d
diff --git a/gcc/testsuite/gfortran.dg/include_13.f90 b/gcc/testsuite/gfortran.dg/include_13.f90
93e26d
new file mode 100644
93e26d
index 00000000000..418ee5585e2
93e26d
--- /dev/null
93e26d
+++ b/gcc/testsuite/gfortran.dg/include_13.f90
93e26d
@@ -0,0 +1,44 @@
93e26d
+! { dg-do compile }
93e26d
+! { dg-options "-fdec" }
93e26d
+subroutine foo
93e26d
+  implicit none
93e26d
+  incl& ! comment1
93e26d
+&u&
93e26d
+       &de           &     ! comment2
93e26d
+'include&
93e26d
+  &_10.inc'
93e26d
+  i = 1
93e26d
+end subroutine foo
93e26d
+subroutine bar
93e26d
+  implicit none
93e26d
+include &
93e26d
+
93e26d
+! comment3
93e26d
+
93e26d
+"include_10.inc"
93e26d
+  i = 1
93e26d
+end subroutine bar
93e26d
+subroutine baz
93e26d
+  implicit none
93e26d
+                                  include&
93e26d
+&'include_10.&
93e26d
+&inc'
93e26d
+  i = 1
93e26d
+end subroutine baz
93e26d
+subroutine qux
93e26d
+  implicit none
93e26d
+  include '&
93e26d
+include_10.inc'
93e26d
+end subroutine qux
93e26d
+subroutine quux
93e26d
+  implicit none
93e26d
+  include &
93e26d
+  &'include_10.inc'
93e26d
+  i = 1
93e26d
+end subroutine quux
93e26d
+subroutine quuz
93e26d
+  implicit none
93e26d
+  include &
93e26d
+  &"include_10.inc"
93e26d
+  i = 1
93e26d
+end subroutine quuz