PR fortran.67802
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 2 Oct 2015 00:53:00 +0000 (00:53 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 2 Oct 2015 00:53:00 +0000 (00:53 +0000)
2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran.67802
* decl.c (add_init_expr_to_sym): Numeric constant for character
length must be an INTEGER.

2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran.67802
* gfortran.dg/pr67802.f90: New test.

From-SVN: r228365

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr67802.f90 [new file with mode: 0644]

index 9e6f2bd..2b6a4b6 100644 (file)
@@ -1,5 +1,11 @@
 2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
+       PR fortran.67802
+       * decl.c (add_init_expr_to_sym): Numeric constant for character
+       length must be an INTEGER.
+
+2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>
+
        PR fortran/66979
        * io.c (gfc_resolve_filepos): Check for a UNIT number.  Add a nearby
        missing 'return false'.
index 39c1136..39e0805 100644 (file)
@@ -1439,7 +1439,12 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
          /* Update initializer character length according symbol.  */
          else if (sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)
            {
-             int len = mpz_get_si (sym->ts.u.cl->length->value.integer);
+             int len;
+
+             if (!gfc_specification_expr (sym->ts.u.cl->length))
+               return false;
+
+             len = mpz_get_si (sym->ts.u.cl->length->value.integer);
 
              if (init->expr_type == EXPR_CONSTANT)
                gfc_set_constant_character_len (len, init, -1);
index ea748b9..f56366a 100644 (file)
@@ -1,5 +1,10 @@
 2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
+       PR fortran.67802
+       * gfortran.dg/pr67802.f90: New test.
+
+2015-10-01  Steven G. Kargl  <kargl@gcc.gnu.org>
+
        PR fortran/66979
        gfortran.dg/pr66979.f90: new test.
 
diff --git a/gcc/testsuite/gfortran.dg/pr67802.f90 b/gcc/testsuite/gfortran.dg/pr67802.f90
new file mode 100644 (file)
index 0000000..6095016
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/67802
+! Original code contribute by gerhard.steinmetz.fortran at t-online.de
+program p
+   character(1.) :: c1 = ' '      ! { dg-error "must be of INTEGER" }
+   character(1d1) :: c2 = ' '     ! { dg-error "must be of INTEGER" }
+   character((0.,1.)) :: c3 = ' ' ! { dg-error "must be of INTEGER" }
+   character(.true.) :: c4 = ' '  ! { dg-error "must be of INTEGER" }
+end program p