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, Commited] PR 34425 - fix extend calc for actual arguments


I committed the attached patch as obvious.

The problem was that the size for full arrays was calculated using
unsigned instead of signed integer. Leading to wrong warnings and
missing warnings.

Build and regtested on x86-64.

Committed to the trunk as Rev. 130752.

Tobias
2007-12-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34425
	* interface.c (get_expr_storage_size): Use signed integer when
	obtaining the bounds.

2007-12-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34425
	* gfortran.dg/argument_checking_10.f90: New.

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 130750)
+++ gcc/fortran/interface.c	(working copy)
@@ -1642,8 +1642,8 @@ get_expr_storage_size (gfc_expr *e)
 	    if (ref->u.ar.as->lower[i] && ref->u.ar.as->upper[i]
 		&& ref->u.ar.as->lower[i]->expr_type == EXPR_CONSTANT
 		&& ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT)
-	      elements *= mpz_get_ui (ref->u.ar.as->upper[i]->value.integer)
-			  - mpz_get_ui (ref->u.ar.as->lower[i]->value.integer)
+	      elements *= mpz_get_si (ref->u.ar.as->upper[i]->value.integer)
+			  - mpz_get_si (ref->u.ar.as->lower[i]->value.integer)
 			  + 1L;
 	    else
 	      return 0;
Index: gcc/testsuite/gfortran.dg/argument_checking_10.f90
===================================================================
--- gcc/testsuite/gfortran.dg/argument_checking_10.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/argument_checking_10.f90	(revision 0)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+!
+! PR fortran/34425
+!
+! Contributed by Joost VandeVondele
+!
+IMPLICIT NONE
+INTEGER :: i(-1:1)
+INTEGER :: j(-2:-1)
+CALL S(i)
+CALL S(j) ! { dg-warning "Actual argument contains too few elements for dummy argument 'i' .2/3." }
+CONTAINS
+ SUBROUTINE S(i)
+  INTEGER :: i(0:2)
+ END SUBROUTINE
+END

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