This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran, Patch] PR34662 - inout argument with parameter


The following simple patch fixes the problem that a parameter actual
argument is accepted for an intent(out)/intent(inout) dummy.

Build and regtested on x86-64-linux. OK for the trunk?

Tobias
2008-01-04  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34662
	* interface.c (compare_actual_formal): Reject parameter
	actual to intent(out) dummy.

2008-01-04  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34662
	* gfortran.dg/intent_out_3.f90: New.

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(Revision 131325)
+++ gcc/fortran/interface.c	(Arbeitskopie)
@@ -1908,13 +1908,15 @@ compare_actual_formal (gfc_actual_arglis
 	}
 
       /* Check intent = OUT/INOUT for definable actual argument.  */
-      if (a->expr->expr_type != EXPR_VARIABLE
+      if ((a->expr->expr_type != EXPR_VARIABLE
+	   || a->expr->symtree->n.sym->attr.flavor != FL_VARIABLE)
 	  && (f->sym->attr.intent == INTENT_OUT
 	      || f->sym->attr.intent == INTENT_INOUT))
 	{
 	  if (where)
-	    gfc_error ("Actual argument at %L must be definable to "
-		       "match dummy INTENT = OUT/INOUT", &a->expr->where);
+	    gfc_error ("Actual argument at %L must be definable as "
+		       "the dummy argument '%s' is INTENT = OUT/INOUT",
+		       &a->expr->where, f->sym->name);
 	  return 0;
 	}
 
Index: gcc/testsuite/gfortran.dg/intent_out_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/intent_out_3.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/intent_out_3.f90	(Revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/34662
+! The INTENT error was not detected.
+! Test case contributed by Joost VandeVondele.
+!
+MODULE M1
+ TYPE T1
+  INTEGER :: I(3)
+ END TYPE T1
+ TYPE(T1), PARAMETER :: D1=T1((/1,2,3/))
+CONTAINS
+ SUBROUTINE S1(J)
+  INTEGER, INTENT(INOUT) :: J
+ END SUBROUTINE S1
+END MODULE M1
+USE M1
+CALL S1(D1%I(3)) ! { dg-error "must be definable" }
+END

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]