re PR fortran/77506 (F2008 Standard does not allow CHARACTER(LEN=*) in array constructor)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 9 Sep 2016 18:04:23 +0000 (18:04 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 9 Sep 2016 18:04:23 +0000 (18:04 +0000)
2016-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/77506
* array.c (gfc_match_array_constructor): CHARACTER(len=*) cannot
appear in an array constructor.

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

PR fortran/77506
* gfortran.dg/pr77506.f90: New test.

From-SVN: r240052

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

index a0afe045b9a567c56917c81ce07c81d77fa83b1e..284bf7d92c0917cad31fe919d5a6ea1b1a42b76f 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77506
+       * array.c (gfc_match_array_constructor): CHARACTER(len=*) cannot
+       appear in an array constructor.
+
 2016-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/77507
index 48a7250d108d6926fae18443bb939a25f7ba7cf0..14e20a36de5577a9c1ada356f547f9512a3afd97 100644 (file)
@@ -1142,6 +1142,15 @@ gfc_match_array_constructor (gfc_expr **result)
              gfc_restore_last_undo_checkpoint ();
              goto cleanup;
            }
+
+         if (ts.type == BT_CHARACTER
+             && ts.u.cl && !ts.u.cl->length && !ts.u.cl->length_from_typespec)
+           {
+             gfc_error ("Type-spec at %L cannot contain an asterisk for a "
+                        "type parameter", &where);
+             gfc_restore_last_undo_checkpoint ();
+             goto cleanup;
+           }
        }
     }
   else if (m == MATCH_ERROR)
index 407bc30084ca0ea6e17557954639847df93b390f..56ff8bc9ff9eee4acd3d7dd40186b5afab9ed396 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/77506
+       * gfortran.dg/pr77506.f90: New test.
+
 2016-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/77507
diff --git a/gcc/testsuite/gfortran.dg/pr77506.f90 b/gcc/testsuite/gfortran.dg/pr77506.f90
new file mode 100644 (file)
index 0000000..70d874e
--- /dev/null
@@ -0,0 +1,4 @@
+! { dg-do compile }
+program foo
+   print *, [character(len=*)::'ab','cd'] ! { dg-error "contain an asterisk" }
+end program foo