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 9e6f2bdbcd530ee955327445a9d68195066d180e..2b6a4b67f6db1ab053a12433436f7a8374b4ec55 100644 (file)
@@ -1,3 +1,9 @@
+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
index 39c1136b68ba2fca180b216dae90af6f6830d67a..39e08055582f48874ad072f8935d84fe9017fdf9 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 ea748b92adc4117bfa3d77b3a20d2dfbc6e2e5f3..f56366a28374a8b8a11c60ea4b4a75f6059f862d 100644 (file)
@@ -1,3 +1,8 @@
+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
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