public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/66106 -- Enforce C1202 from F2008
@ 2015-05-15 15:34 Steve Kargl
  2015-05-15 15:56 ` FX
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2015-05-15 15:34 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

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.

-- 
Steve

[-- Attachment #2: pr66106.diff --]
[-- Type: text/x-diff, Size: 1274 bytes --]

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" }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fortran/66106 -- Enforce C1202 from F2008
  2015-05-15 15:34 [PATCH] fortran/66106 -- Enforce C1202 from F2008 Steve Kargl
@ 2015-05-15 15:56 ` FX
  2015-05-15 16:09   ` Steve Kargl
  0 siblings, 1 reply; 4+ messages in thread
From: FX @ 2015-05-15 15:56 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

 - 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fortran/66106 -- Enforce C1202 from F2008
  2015-05-15 15:56 ` FX
@ 2015-05-15 16:09   ` Steve Kargl
  2015-05-15 18:17     ` FX
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2015-05-15 16:09 UTC (permalink / raw)
  To: FX; +Cc: fortran, gcc-patches

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.

-- 
Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fortran/66106 -- Enforce C1202 from F2008
  2015-05-15 16:09   ` Steve Kargl
@ 2015-05-15 18:17     ` FX
  0 siblings, 0 replies; 4+ messages in thread
From: FX @ 2015-05-15 18:17 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-15 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 15:34 [PATCH] fortran/66106 -- Enforce C1202 from F2008 Steve Kargl
2015-05-15 15:56 ` FX
2015-05-15 16:09   ` Steve Kargl
2015-05-15 18:17     ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).