diff mbox

[fortram] PR64506 FORMAT Parse Error with Continuation Line

Message ID 54CE1FAA.8040703@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Feb. 1, 2015, 12:44 p.m. UTC
The attached patch fixes this issue.

Regression tested on x86-64.

New test case attached.

OK for trunk?

Regards,

Jerry

2015-02-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/64506
	* scanner.c (gfc_next_char_literal): Check for '!' and if found,
	clear the comment and go back and get the next character.

Comments

Jerry DeLisle Feb. 1, 2015, 5:56 p.m. UTC | #1
After Stage 4 of course.

On 02/01/2015 04:44 AM, Jerry DeLisle wrote:
> The attached patch fixes this issue.
>
> Regression tested on x86-64.
>
> New test case attached.
>
> OK for trunk?
>
> Regards,
>
> Jerry
>
> 2015-02-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
>
>      PR fortran/64506
>      * scanner.c (gfc_next_char_literal): Check for '!' and if found,
>      clear the comment and go back and get the next character.
Tobias Burnus Feb. 1, 2015, 9:02 p.m. UTC | #2
Jerry DeLisle wrote:
> The attached patch fixes this issue.
> Regression tested on x86-64.
> New test case attached.
>
> OK for trunk?
Looks ok (together with a changelog for the test case).

However, I tried a similar fixed-form program and it failed similarly. I 
think you need a similar fix (in the same function) for fixed-form 
source code. See attachment for an example.

Tobias


> 2015-02-01 Jerry DeLisle  <jvdelisle@gcc.gnu.org>
>
>     PR fortran/64506
>     * scanner.c (gfc_next_char_literal): Check for '!' and if found,
>     clear the comment and go back and get the next character.
Jerry DeLisle Feb. 2, 2015, 4:43 a.m. UTC | #3
On 02/01/2015 08:34 PM, Jerry DeLisle wrote:

The test case should have the print *, astring changed to call abort.

Jerry
diff mbox

Patch

Index: scanner.c
===================================================================
--- scanner.c	(revision 220307)
+++ scanner.c	(working copy)
@@ -1268,13 +1268,25 @@  restart:
 	c = next_char ();
 
       /* Character constants to be continued cannot have commentary
-	 after the '&'.  */
+	 after the '&'. However, there are cases where we may think we
+	 are still in a string and we are looking for a possible
+	 doubled quote and we end up here. See PR64506.  */
 
-      if (in_string && c != '\n')
+      if (in_string)
 	{
 	  gfc_current_locus = old_loc;
-	  c = '&';
-	  goto done;
+
+	  if (c == '!')
+	    {
+	      skip_comment_line ();
+	      goto restart;
+	    }
+
+	  if (c != '\n')
+	    {
+	      c = '&';
+	      goto done;
+	    }
 	}
 
       if (c != '!' && c != '\n')