Patchwork [fortran] PR44347 - ensure scalar arguments for selected_real_kind

login
register
mail settings
Submitter Daniel Franke
Date June 9, 2010, 8:59 p.m.
Message ID <201006092259.24398.franke@embl-hamburg.de>
Download mbox | patch
Permalink /patch/55127/
State New
Headers show

Comments

Daniel Franke - June 9, 2010, 8:59 p.m.
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
Steve Kargl - June 9, 2010, 9:23 p.m.
On Wed, Jun 09, 2010 at 10:59:24PM +0200, Daniel Franke wrote:
> 
> 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)?
> 

OK.

Patch

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;
 }