diff mbox

fortran/66106 -- Enforce C1202 from F2008

Message ID 20150515152547.GI82729@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl May 15, 2015, 3:25 p.m. UTC
Regression tested on trunk.  OK to commit?

The patch allows gfortran to check a portion of C1202
that was previously mishandled.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66057
	* interface.c(gfc_match_end_interface): Enfornce F2008 C1202 (R1201).

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66057
	* gfortran.dg/interface_operator_1.f90: New tests.

Comments

FX Coudert May 15, 2015, 3:45 p.m. UTC | #1
- You’re missing the match.c part of the patch (I really had a hard time figuring out how the patch was supposed to work! then I read the one posted in the PR)
 - Let’s avoid the strcmp() string comparison and use “op == INTRINSIC_NONE” as the condition (seems clearer and more efficient to me)
 - Maybe not doing all the tests (those after "The following if-statements”) if op == INTRINSIC_NONE, as all the s2 comparisons will be false.
 - The PR number in the ChangeLog is wrong (both times)

With the above fixed, it’s OK.
Thanks for taking care of all this!

FX
Steve Kargl May 15, 2015, 4:03 p.m. UTC | #2
On Fri, May 15, 2015 at 05:45:54PM +0200, FX wrote:
>  - You're missing the match.c part of the patch (I really had
>  a hard time figuring out how the patch was supposed to work!
>  then I read the one posted in the PR)

Whoops, sorry about that.  As you can see I have small patches
sitting in my tree.  I tried to untangle the 'svn diff'

>  - Let's avoid the strcmp() string comparison and use
> 'op == INTRINSIC_NONE' as the condition (seems clearer and more
> efficient to me)
>  - Maybe not doing all the tests (those after "The following
>  if-statements") if op == INTRINSIC_NONE, as all the s2
>  comparisons will be false.
>  - The PR number in the ChangeLog is wrong (both times)

Whoops copy-n-paste from one log to another.

> With the above fixed, it???s OK.
> Thanks for taking care of all this!

I'll rework the patch to address your 2 suggestions.
FX Coudert May 15, 2015, 6:13 p.m. UTC | #3
> Whoops, sorry about that.  As you can see I have small patches
> sitting in my tree.  I tried to untangle the 'svn diff’

Thanks for cleaning and submitting those! I’ll try to review them over the next 2 days, if nobody beats me to it :)

FX
diff mbox

Patch

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 223094)
+++ gcc/fortran/interface.c	(working copy)
@@ -346,8 +346,12 @@  gfc_match_end_interface (void)
 		break;
 
 	      m = MATCH_ERROR;
-	      gfc_error ("Expecting %<END INTERFACE OPERATOR (%s)%> at %C, "
-			 "but got %s", s1, s2);
+	      if (strcmp(s2, "none") == 0)
+		gfc_error ("Expecting %<END INTERFACE OPERATOR (%s)%> "
+			   "at %C, ", s1);
+	      else		
+		gfc_error ("Expecting %<END INTERFACE OPERATOR (%s)%> at %C, "
+			   "but got %s", s1, s2);
 	    }
 
 	}
Index: gcc/testsuite/gfortran.dg/interface_operator_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/interface_operator_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/interface_operator_1.f90	(working copy)
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+! PR fortran/66106
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   interface operator ( .gt. )
+   end interface operator        ! { dg-error "END INTERFACE OPERATOR" }
+end program p                    ! { dg-error "END INTERFACE" }
+! { dg-excess-errors "Unexpected end of file" }