This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[4.3/4.4 Regression] Wrong locus for errors in DATA statement


Dear All

This is another simple, going on obvious, PR: Somewhere, I do not know
where, the value expressions for data statements are losing their
correct locus on simplification or substitution and the declaration
locus for the parameter used instead.  On noting that the condition
conform == 0 in gfc_check_assign only emerges from checking data
statements, it was much simpler to substitute the rvalue locus by that
of the lvaue in the error message.  The testcase is the reporter's.

Bootstrapped and regtested on x86_ia64/FC8 - OK for trunk and 4.3?

Paul

2008-06-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34371
	* expr.c (gfc_check_assign):  Change message and locus for
	error when conform == 0.

2008-06-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/36371
	* gfortran.dg/data_array_5.f90: New test.
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c	(revision 136870)
--- gcc/fortran/expr.c	(working copy)
*************** gfc_check_assign (gfc_expr *lvalue, gfc_
*** 2829,2834 ****
--- 2829,2835 ----
    if (gfc_compare_types (&lvalue->ts, &rvalue->ts))
      return SUCCESS;
  
+   /* Only DATA Statements come here.  */
    if (!conform)
      {
        /* Numeric can be converted to any other numeric. And Hollerith can be
*************** gfc_check_assign (gfc_expr *lvalue, gfc_
*** 2840,2848 ****
        if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
  	return SUCCESS;
  
!       gfc_error ("Incompatible types in assignment at %L; attempted assignment "
! 		 "of %s to %s", &rvalue->where, gfc_typename (&rvalue->ts),
! 		 gfc_typename (&lvalue->ts));
  
        return FAILURE;
      }
--- 2841,2849 ----
        if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
  	return SUCCESS;
  
!       gfc_error ("Incompatible types in DATA statement at %L; attempted "
! 		 "conversion of %s to %s", &lvalue->where,
! 		 gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts));
  
        return FAILURE;
      }
Index: gcc/testsuite/gfortran.dg/data_array_5.f90
===================================================================
*** gcc/testsuite/gfortran.dg/data_array_5.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/data_array_5.f90	(revision 0)
***************
*** 0 ****
--- 1,14 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR36371, in which the locus for the errors pointed to
+ ! the paramter declaration rather than the data statement.
+ !
+ ! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
+ !
+ program chkdata
+   character(len=3), parameter :: mychar(3) = [ "abc", "def", "ghi" ]
+   integer, parameter :: myint(3) = [1, 2, 3]
+   integer :: c(2)
+   character(4) :: i(2)
+   data c / mychar(1), mychar(3) / ! { dg-error "Incompatible types in DATA" }
+   data i / myint(3), myint(2) /   ! { dg-error "Incompatible types in DATA" }
+ end program chkdata

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