re PR fortran/16907 (Non-integer array indices rejected)
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Sun, 13 Mar 2005 18:46:36 +0000 (19:46 +0100)
committerTobias Schlüter <tobi@gcc.gnu.org>
Sun, 13 Mar 2005 18:46:36 +0000 (19:46 +0100)
fortran/
PR fortran/16907
* resolve.c (gfc_resolve_index): Allow REAL indices as an extension.

testsuite/
PR fortran/16907
* gfortran.dg/real_index_1.f90: New test.

From-SVN: r96385

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

index d4823b3e153c291715b77239b3c11cf52a6a7e4c..f116966ebdcec945ea521e5afc81aaf65a2bf88c 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-13  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/16907
+       * resolve.c (gfc_resolve_index): Allow REAL indices as an extension.
+
 2005-03-13  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/20323
index b51206f91b748dc18d63b7bc532e5d7d87b5c1d1..35795c3ff2a3f0fb53001dd6f6539e3abfa2964d 100644 (file)
@@ -1701,19 +1701,26 @@ gfc_resolve_index (gfc_expr * index, int check_scalar)
   if (gfc_resolve_expr (index) == FAILURE)
     return FAILURE;
 
-  if (index->ts.type != BT_INTEGER)
+  if (check_scalar && index->rank != 0)
     {
-      gfc_error ("Array index at %L must be of INTEGER type", &index->where);
+      gfc_error ("Array index at %L must be scalar", &index->where);
       return FAILURE;
     }
 
-  if (check_scalar && index->rank != 0)
+  if (index->ts.type != BT_INTEGER && index->ts.type != BT_REAL)
     {
-      gfc_error ("Array index at %L must be scalar", &index->where);
+      gfc_error ("Array index at %L must be of INTEGER type",
+                &index->where);
       return FAILURE;
     }
 
-  if (index->ts.kind != gfc_index_integer_kind)
+  if (index->ts.type == BT_REAL)
+    if (gfc_notify_std (GFC_STD_GNU, "Extension: REAL array index at %L",
+                       &index->where) == FAILURE)
+      return FAILURE;
+
+  if (index->ts.kind != gfc_index_integer_kind
+      || index->ts.type != BT_INTEGER)
     {
       ts.type = BT_INTEGER;
       ts.kind = gfc_index_integer_kind;
index d3b3eb591cca62753af7034df14b4ce3102c93be..bcc841588f610acf00173a2060d538e577a6d09a 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-13  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/16907
+       * gfortran.dg/real_index_1.f90: New test.
+
 2005-03-13  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/20323
diff --git a/gcc/testsuite/gfortran.dg/real_index_1.f90 b/gcc/testsuite/gfortran.dg/real_index_1.f90
new file mode 100644 (file)
index 0000000..16ceca8
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do run }
+! PR 16907 : We didn't support REAL array indices as an extension
+       integer I, A(10)
+       A = 2
+       I=A(1.0) ! { dg-warning "Extension" }
+       if (i/=2) call abort ()
+       end