]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/86059 (ICE in reduce_binary_ac, at fortran/arith.c:1308 (and others))
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 9 Jun 2018 18:54:56 +0000 (18:54 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 9 Jun 2018 18:54:56 +0000 (18:54 +0000)
2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/86059
* array.c (match_array_cons_element): NULL() cannot be in an
array constructor.

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

PR fortran/86059
* gfortran.dg/associate_30.f90: Remove code tested ...
* gfortran.dg/pr67803.f90: Ditto.
* gfortran.dg/pr67805.f90: Ditto.
* gfortran.dg/pr86059.f90: ... here.  New test.

From-SVN: r261373

gcc/fortran/ChangeLog
gcc/fortran/array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/associate_30.f90
gcc/testsuite/gfortran.dg/pr67803.f90
gcc/testsuite/gfortran.dg/pr67805.f90
gcc/testsuite/gfortran.dg/pr86059.f90 [new file with mode: 0644]

index f311df1cf3815ad38aec9f0201be2ab40d9af082..8ba1206d5b3e684d96a1d153f78d8da7f5fbfa8e 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/86059
+       * array.c (match_array_cons_element): NULL() cannot be in an
+       array constructor.
+
 2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85138
index e3a8e35ed75edbde1f9ca485da2bc1fdd3312603..e35c67abd5d78d1c9f9688fdd02415f4374e35d7 100644 (file)
@@ -1079,6 +1079,15 @@ match_array_cons_element (gfc_constructor_base *result)
   if (m != MATCH_YES)
     return m;
 
+  if (expr->expr_type == EXPR_FUNCTION
+      && expr->ts.type == BT_UNKNOWN
+      && strcmp(expr->symtree->name, "null") == 0)
+   {
+      gfc_error ("NULL() at %C cannot appear in an array constructor");
+      gfc_free_expr (expr);
+      return MATCH_ERROR;
+   }
+
   gfc_constructor_append_expr (result, expr, &gfc_current_locus);
   return MATCH_YES;
 }
index 0c5cbb79e5d303242ae50fcbdc72d2d822f93e58..301b1555af9b406db8d266e4f564d4da70270f29 100644 (file)
@@ -1,3 +1,11 @@
+2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/86059
+       * gfortran.dg/associate_30.f90: Remove code tested ...
+       * gfortran.dg/pr67803.f90: Ditto.
+       * gfortran.dg/pr67805.f90: Ditto.
+       * gfortran.dg/pr86059.f90: ... here.  New test.
+
 2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85138
index ad15d8bf576f36a9ee6875b0cce5beeb76a3ae12..ecc9ad06a5620069fbe1b6bbd1220ce06d58808f 100644 (file)
@@ -8,8 +8,3 @@
       associate (x => null())   ! { dg-error "cannot be NULL()" }
       end associate
    end subroutine
-
-   subroutine s2
-      associate (x => [null()]) ! { dg-error "has no type" }
-      end associate
-   end subroutine
index 9a8ff309feb1ee887ced08785f6d59da48d2ad6f..55a1bbf579442345cc633bcb15ff4012f8fe5bcc 100644 (file)
@@ -10,5 +10,4 @@ program p
   x = '0' // [character :: 1d1]     ! { dg-error "Incompatible typespec for" }
   x = '0' // [character :: (0.,1.)] ! { dg-error "Incompatible typespec for" }
   x = '0' // [character :: .true.]  ! { dg-error "Incompatible typespec for" }
-  x = '0' // [character :: null()]  ! { dg-error "Incompatible typespec for" }
 end
index 7371991717d820c32e638788dd2f349d684adeef..2aedde8977b4bfb4f0a106a1b2e04a76f447a2bc 100644 (file)
@@ -22,7 +22,6 @@ subroutine p
    s = [character([1.]) :: 'x', 'y']      ! { dg-error "INTEGER expression expected" }
    s = [character([1d1]) :: 'x', 'y']     ! { dg-error "INTEGER expression expected" }
    s = [character([(0.,1.)]) :: 'x', 'y'] ! { dg-error "INTEGER expression expected" }
-   s = [character([null()]) :: 'x', 'y']  ! { dg-error "INTEGER expression expected" }
    s =  [character(null()) :: 'x', 'y']   ! { dg-error "INTEGER expression expected" }
    call foo(s)
 end subroutine p
diff --git a/gcc/testsuite/gfortran.dg/pr86059.f90 b/gcc/testsuite/gfortran.dg/pr86059.f90
new file mode 100644 (file)
index 0000000..e0caed1
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/86059
+program foo
+   integer :: i(2) = [ null(), 1 ]           ! { dg-error "cannot appear in an array constructor" }
+   integer :: j(2) = [ (null(), n = 1, 2) ]  ! { dg-error "cannot appear in an array constructor" }
+   integer k(2)
+   k = 42 + [1, null()]                      ! { dg-error "cannot appear in an array constructor" }
+end program foo