This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Committed] PR fortran/87945 -- Inquiry parameter in data statement


An inquiry parameter cannot be a data object.

20180-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/87945
	* decl.c (var_element): Inquiry parameters cannit be data objects.

20180-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/87945
	* gfortran.dg/pr87945_1.f90: New test.
	* gfortran.dg/pr87945_2.f90: New test.

-- 
Steve
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 266912)
+++ gcc/fortran/decl.c	(working copy)
@@ -281,6 +281,14 @@ var_element (gfc_data_variable *new_var)
   if (m != MATCH_YES)
     return m;
 
+  if (new_var->expr->expr_type == EXPR_CONSTANT
+      && new_var->expr->symtree == NULL)
+    {
+      gfc_error ("Inquiry parameter cannot appear in a "
+		 "data-stmt-object-list at %C");
+      return MATCH_ERROR;
+    }
+
   sym = new_var->expr->symtree->n.sym;
 
   /* Symbol should already have an associated type.  */
Index: gcc/testsuite/gfortran.dg/pr87945_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87945_1.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87945_1.f90	(working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/87945
+program p
+   character :: a, b
+   data a%len /1/       ! { dg-error "parameter cannot appear in" }
+   data b%kind /'b'/    ! { dg-error "parameter cannot appear in" }
+end
Index: gcc/testsuite/gfortran.dg/pr87945_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87945_2.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87945_2.f90	(working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/87945
+program p
+   character :: a, b
+   a%len = 1      ! { dg-error "to a constant expression" }
+   b%kind = 'b'   ! { dg-error "to a constant expression" }
+end

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