Commit f2bc4e48 by Steven G. Kargl

re PR fortran/77391 (gfortran allows CHARACTER(LEN=:),PARAMETER::…

re PR fortran/77391 (gfortran allows CHARACTER(LEN=:),PARAMETER:: STRING='constant'   buts does not report it as an extension)

2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/77391
	* resolve.c (deferred_requirements): New function to check F2008:C402.
	(resolve_fl_variable,resolve_fl_parameter): Use it.
 
2016-09-04  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/77391
	* gfortran.dg/pr77391.f90: New test.

From-SVN: r239982
parent aa9cdb97
2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> 2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77391
* resolve.c (deferred_requirements): New function to check F2008:C402.
(resolve_fl_variable,resolve_fl_parameter): Use it.
2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77460 PR fortran/77460
* simplify.c (simplify_transformation_to_scalar): On error, result * simplify.c (simplify_transformation_to_scalar): On error, result
may be NULL, simply return. may be NULL, simply return.
......
...@@ -11488,6 +11488,27 @@ resolve_fl_variable_derived (gfc_symbol *sym, int no_init_flag) ...@@ -11488,6 +11488,27 @@ resolve_fl_variable_derived (gfc_symbol *sym, int no_init_flag)
} }
/* F2008, C402 (R401): A colon shall not be used as a type-param-value
except in the declaration of an entity or component that has the POINTER
or ALLOCATABLE attribute. */
static bool
deferred_requirements (gfc_symbol *sym)
{
if (sym->ts.deferred
&& !(sym->attr.pointer
|| sym->attr.allocatable
|| sym->attr.omp_udr_artificial_var))
{
gfc_error ("Entity %qs at %L has a deferred type parameter and "
"requires either the POINTER or ALLOCATABLE attribute",
sym->name, &sym->declared_at);
return false;
}
return true;
}
/* Resolve symbols with flavor variable. */ /* Resolve symbols with flavor variable. */
static bool static bool
...@@ -11527,17 +11548,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) ...@@ -11527,17 +11548,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
} }
/* Constraints on deferred type parameter. */ /* Constraints on deferred type parameter. */
if (sym->ts.deferred if (!deferred_requirements (sym))
&& !(sym->attr.pointer
|| sym->attr.allocatable
|| sym->attr.omp_udr_artificial_var))
{
gfc_error ("Entity %qs at %L has a deferred type parameter and "
"requires either the pointer or allocatable attribute",
sym->name, &sym->declared_at);
specification_expr = saved_specification_expr;
return false; return false;
}
if (sym->ts.type == BT_CHARACTER) if (sym->ts.type == BT_CHARACTER)
{ {
...@@ -13682,6 +13694,10 @@ resolve_fl_parameter (gfc_symbol *sym) ...@@ -13682,6 +13694,10 @@ resolve_fl_parameter (gfc_symbol *sym)
return false; return false;
} }
/* Constraints on deferred type parameter. */
if (!deferred_requirements (sym))
return false;
/* Make sure a parameter that has been implicitly typed still /* Make sure a parameter that has been implicitly typed still
matches the implicit type, since PARAMETER statements can precede matches the implicit type, since PARAMETER statements can precede
IMPLICIT statements. */ IMPLICIT statements. */
......
2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> 2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77391
* gfortran.dg/pr77391.f90: New test.
2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77460 PR fortran/77460
* gfortran.dg/pr77460.f90: New test. * gfortran.dg/pr77460.f90: New test.
......
! { dg-do compile }
program picky
character(len=:), parameter :: a="whoops" ! { dg-error "POINTER or ALLOCATABLE" }
character(len=:) :: b="whoops" ! { dg-error "POINTER or ALLOCATABLE" }
character(len=:) :: good
pointer good
end program picky
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment