This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR fortran/71730 -- Patch
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 Jul 2016 14:17:41 -0700
- Subject: PR fortran/71730 -- Patch
- Authentication-results: sourceware.org; auth=none
I plan to commit the following patch in the next day or
two if no one objects. It falls into the trivially
correct category.
2016-07-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71730
* decl.c (match_data_constant): Set 'result' to NULL in error case.
(char_len_param_value): Check return for gfc_reduce_init_expr().
2016-07-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71730
* gfortran.dg/pr71730.f90: New test.
* gfortran.dg/bounds_check_strlen_2.f90: Fix invalid code.
* gfortran.dg/array_constructor_27.f03: Update dg-error message.
* gfortran.dg/array_constructor_26.f03: Ditto.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 238824)
+++ gcc/fortran/decl.c (working copy)
@@ -395,6 +395,7 @@ match_data_constant (gfc_expr **result)
{
gfc_error ("Symbol %qs must be a PARAMETER in DATA statement at %C",
name);
+ *result = NULL;
return MATCH_ERROR;
}
else if (dt_sym && gfc_fl_struct (dt_sym->attr.flavor))
@@ -905,6 +906,7 @@ char_len_param_value (gfc_expr **expr, b
goto syntax;
else if ((*expr)->expr_type == EXPR_VARIABLE)
{
+ bool t;
gfc_expr *e;
e = gfc_copy_expr (*expr);
@@ -916,7 +918,15 @@ char_len_param_value (gfc_expr **expr, b
&& e->ref->u.ar.dimen_type[0] == DIMEN_RANGE)
goto syntax;
- gfc_reduce_init_expr (e);
+ t = gfc_reduce_init_expr (e);
+
+ if (!t && (e->ts.type == BT_UNKNOWN
+ && e->symtree->n.sym->attr.untyped == 1
+ && e->symtree->n.sym->ns->seen_implicit_none == 1))
+ {
+ gfc_free_expr (e);
+ goto syntax;
+ }
if ((e->ref && e->ref->type == REF_ARRAY
&& e->ref->u.ar.type != AR_ELEMENT)
Index: gcc/testsuite/gfortran.dg/pr71730.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr71730.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr71730.f90 (working copy)
@@ -0,0 +1,5 @@
+! { dg-do compile }
+subroutine foo
+ implicit none
+ character(len=bar) :: a ! { dg-error "Scalar INTEGER expression" }
+end subroutine foo
Index: gcc/testsuite/gfortran.dg/bounds_check_strlen_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/bounds_check_strlen_2.f90 (revision 238829)
+++ gcc/testsuite/gfortran.dg/bounds_check_strlen_2.f90 (working copy)
@@ -11,8 +11,8 @@ CONTAINS
SUBROUTINE test (str, n)
IMPLICIT NONE
- CHARACTER(len=n) :: str
INTEGER :: n
+ CHARACTER(len=n) :: str
END SUBROUTINE test
SUBROUTINE test2 (str)
Index: gcc/testsuite/gfortran.dg/array_constructor_27.f03
===================================================================
--- gcc/testsuite/gfortran.dg/array_constructor_27.f03 (revision 238829)
+++ gcc/testsuite/gfortran.dg/array_constructor_27.f03 (working copy)
@@ -8,8 +8,7 @@
implicit none
type t
- character (a) :: arr (1) = [ "a" ]
- ! { dg-error "specification expression" "" { target *-*-* } 11 }
+ character (a) :: arr (1) = [ "a" ] ! { dg-error "Scalar INTEGER expression" }
end type t
end
Index: gcc/testsuite/gfortran.dg/array_constructor_26.f03
===================================================================
--- gcc/testsuite/gfortran.dg/array_constructor_26.f03 (revision 238829)
+++ gcc/testsuite/gfortran.dg/array_constructor_26.f03 (working copy)
@@ -10,7 +10,6 @@ MODULE WinData
INTEGER (1), PARAMETER :: MAXFLD = 25_1, MAXHED = 5_1, MAXCHR = 80_1
integer :: i
TYPE TWindowData
- CHARACTER (MAX_FLD_HED, 1) :: DWFdHd(MAXFLD) = [(" ", i = 1, MAXFLD)]
- ! { dg-error "specification expression" "" { target *-*-* } 13 }
+ CHARACTER (MAX_FLD_HED, 1) :: DWFdHd(MAXFLD) = [(" ", i = 1, MAXFLD)] ! { dg-error "Scalar INTEGER expression" }
END TYPE TWindowData
END MODULE WinData
--
Steve