This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR44347 - ensure scalar arguments for selected_real_kind


Pretty obvious.


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.


Regression tested on i686-pc-linux-gnu.
Ok for trunk (accepts-invalid)? 4.5 (ICE)?

	Daniel
Index: check.c
===================================================================
--- check.c	(revision 160504)
+++ check.c	(working copy)
@@ -2930,11 +2930,23 @@ gfc_check_selected_real_kind (gfc_expr *
       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;
 }
! { 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]