diff mbox

fortran/66057 -- detect malformed GENERIC statement

Message ID 20150515152345.GH82729@troutmask.apl.washington.edu
State New
Headers show

Commit Message

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

See the test case for the type of error that this patch
catches.

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

	PR fortran/66057
	* decl.c(gfc_match_generic):  Detected a malformed GENERIC statement.

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

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

Comments

FX Coudert May 15, 2015, 8:37 p.m. UTC | #1
Does it also catch the other cases shown in the PR? Things like:

      generic :: 2
      generic :: 2 =
      generic :: 1 => x
      generic :: ?

etc.

OK if so. If not, maybe it’s worth adding them at the same time?

FX
Steve Kargl May 18, 2015, 11 p.m. UTC | #2
On Fri, May 15, 2015 at 10:37:24PM +0200, FX wrote:
> Does it also catch the other cases shown in the PR? Things like:
> 
>       generic :: 2
>       generic :: 2 =
>       generic :: 1 => x
>       generic :: ?
> 

Yes, the patch appears to catch those as well.
FX Coudert May 19, 2015, 6:30 a.m. UTC | #3
> Yes, the patch appears to catch those as well.

Then: OK to commit.

Thanks!
FX
diff mbox

Patch

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 223094)
+++ gcc/fortran/decl.c	(working copy)
@@ -8510,6 +8511,11 @@  gfc_match_generic (void)
 		gfc_op2string (op));
       break;
 
+    case INTERFACE_NAMELESS:
+      gfc_error ("Malformed GENERIC statement at %C");
+      goto error;
+      break;
+
     default:
       gcc_unreachable ();
     }
Index: gcc/testsuite/gfortran.dg/generic_29.f90
===================================================================
--- gcc/testsuite/gfortran.dg/generic_29.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/generic_29.f90	(working copy)
@@ -0,0 +1,11 @@ 
+! { dg-do compile}
+! PR fortran/66057
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   type t
+      contains
+      generic :: ! { dg-error "Malformed GENERIC" }
+   end type
+end