Hi all,

attached is a small patch that approves some diagnostics for INTENT
declarations. It also takes care of a TODO note in decl.c.

I had regtested a previous version of the patch without problems and
will do another run with this one before checking in. Ok for trunk?

Cheers,
Janus


2018-06-09  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/85088
    * decl.c (match_attr_spec): Synchronize the DECL_* enum values with the
    INTENT_* values from the enum 'sym_intent'. Call 'match_intent_spec'
    and remove a TODO note.

2018-06-09  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/85088
    * gfortran.dg/intent_decl_1.f90: New test case.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 261358)
+++ gcc/fortran/decl.c	(working copy)
@@ -4716,9 +4716,10 @@ match_attr_spec (void)
 {
   /* Modifiers that can exist in a type statement.  */
   enum
-  { GFC_DECL_BEGIN = 0,
-    DECL_ALLOCATABLE = GFC_DECL_BEGIN, DECL_DIMENSION, DECL_EXTERNAL,
-    DECL_IN, DECL_OUT, DECL_INOUT, DECL_INTRINSIC, DECL_OPTIONAL,
+  { GFC_DECL_BEGIN = 0, DECL_ALLOCATABLE = GFC_DECL_BEGIN,
+    DECL_IN = INTENT_IN, DECL_OUT = INTENT_OUT, DECL_INOUT = INTENT_INOUT,
+    DECL_DIMENSION, DECL_EXTERNAL,
+    DECL_INTRINSIC, DECL_OPTIONAL,
     DECL_PARAMETER, DECL_POINTER, DECL_PROTECTED, DECL_PRIVATE,
     DECL_STATIC, DECL_AUTOMATIC,
     DECL_PUBLIC, DECL_SAVE, DECL_TARGET, DECL_VALUE, DECL_VOLATILE,
@@ -4846,13 +4847,12 @@ match_attr_spec (void)
 		      if (match_string_p ("nt"))
 			{
 			  /* Matched "intent".  */
-			  /* TODO: Call match_intent_spec from here.  */
-			  if (gfc_match (" ( in out )") == MATCH_YES)
-			    d = DECL_INOUT;
-			  else if (gfc_match (" ( in )") == MATCH_YES)
-			    d = DECL_IN;
-			  else if (gfc_match (" ( out )") == MATCH_YES)
-			    d = DECL_OUT;
+			  d = match_intent_spec ();
+			  if (d == INTENT_UNKNOWN)
+			    {
+			      m = MATCH_ERROR;
+			      goto cleanup;
+			    }
 			}
 		    }
 		  else if (ch == 'r')
! { dg-do compile }
!
! PR 85088: improve diagnostic for bad INTENT declaration
!
! Contributed by Janus Weil <ja...@gcc.gnu.org>

subroutine s(x, y, z)
   integer, intent(int) :: x  ! { dg-error "Bad INTENT specification" }
   integer, intent :: y       ! { dg-error "Bad INTENT specification" }
   integer, inten  :: z       ! { dg-error "Invalid character" }
end

Reply via email to