re PR fortran/44347 (SELECT_REAL_KIND: Wrongly accepts non-scalar arguments)
authorDaniel Franke <franke.daniel@gmail.com>
Wed, 9 Jun 2010 21:36:33 +0000 (17:36 -0400)
committerDaniel Franke <dfranke@gcc.gnu.org>
Wed, 9 Jun 2010 21:36:33 +0000 (17:36 -0400)
gcc/fortran/:
2010-06-09  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/44347
        * check.c (gfc_check_selected_real_kind): Verify that the
        actual arguments are scalar.

gcc/testsuite/:
2010-06-09  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/44347
        * gfortran.dg/selected_real_kind_1.f90: New.

From-SVN: r160506

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

index cafbd314b2efc7210dd598a7869be699396b7a92..c67dd8f58797e24013a9a5c297f17059baa1dc7f 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
+
+        PR fortran/44347
+        * check.c (gfc_check_selected_real_kind): Verify that the
+        actual arguments are scalar.
+
 2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/44359
index 6a5c263ed50283ca1df7df053c2c7559838dfcf5..81f3e24847b96f2d6acc4126720ee43c2ee4221e 100644 (file)
@@ -2930,11 +2930,23 @@ gfc_check_selected_real_kind (gfc_expr *p, gfc_expr *r)
       return FAILURE;
     }
 
-  if (p != NULL && type_check (p, 0, BT_INTEGER) == FAILURE)
-    return FAILURE;
+  if (p)
+    {
+      if (type_check (p, 0, BT_INTEGER) == FAILURE)
+       return FAILURE;
 
-  if (r != NULL && type_check (r, 1, BT_INTEGER) == FAILURE)
-    return FAILURE;
+      if (scalar_check (p, 0) == FAILURE)
+       return FAILURE;
+    }
+
+  if (r)
+    {
+      if (type_check (r, 1, BT_INTEGER) == FAILURE)
+       return FAILURE;
+
+      if (scalar_check (r, 1) == FAILURE)
+       return FAILURE;
+    }
 
   return SUCCESS;
 }
index 5dcee0fb166163fa4cc6d9945b7346071c629607..d0154a9fe27f3c9418297ffc5e87a378b4567e3c 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
+
+        PR fortran/44347
+        * gfortran.dg/selected_real_kind_1.f90: New.
+
 2010-06-09  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/44359
diff --git a/gcc/testsuite/gfortran.dg/selected_real_kind_1.f90 b/gcc/testsuite/gfortran.dg/selected_real_kind_1.f90
new file mode 100644 (file)
index 0000000..0f40a59
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do "compile" }
+!
+! PR fortran/44347 - arguments of SELECTED_REAL_KIND shall be scalar
+! Testcase contributed by Vittorio Zecca <zeccav AT gmail DOT com>
+!
+
+  dimension ip(1), ir(1)
+  i = selected_real_kind(ip, i)      ! { dg-error "must be a scalar" }
+  j = selected_real_kind(i, ir)      ! { dg-error "must be a scalar" }
+end