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
This commit is contained in:
Steven G. Kargl 2016-09-04 20:00:48 +00:00
parent aa9cdb9755
commit f2bc4e4800
4 changed files with 45 additions and 11 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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. */
static bool
@ -11527,17 +11548,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
}
/* Constraints on deferred type parameter. */
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);
specification_expr = saved_specification_expr;
return false;
}
if (!deferred_requirements (sym))
return false;
if (sym->ts.type == BT_CHARACTER)
{
@ -13682,6 +13694,10 @@ resolve_fl_parameter (gfc_symbol *sym)
return false;
}
/* Constraints on deferred type parameter. */
if (!deferred_requirements (sym))
return false;
/* Make sure a parameter that has been implicitly typed still
matches the implicit type, since PARAMETER statements can precede
IMPLICIT statements. */

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,7 @@
! { 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