This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[4.3/4.4 Regression] Wrong locus for errors in DATA statement
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Jun 2008 08:17:30 +0200
- Subject: [4.3/4.4 Regression] Wrong locus for errors in DATA statement
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=6hSmaBfvbGv10goy+GnmsaPRA7l1HvCyc+FzZwgGixY=; b=WLtZ/Phv76cb/vXhbrwomCLORED6FSghcpVwm2iZPK353f/B1xrG15763RufmNAvZ4 ElmrpI9dMqhYFEZZR2kAdB8Wm4aMAV4B/uarL//yWshIWRgvuxqwGoakvfeuGGhzsZPy qaqJWwOWsClssHKif08VSMcL4fBPp/9DqGniQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=BsN2xeXbjtddQQiPFxtPd1LfEtHWZU7Yy5EYlYqD27ltUxmjP42CvVfY45sVdCIvp2 86si0PzWiCw6+HltXlYI1uSnPFHLD0RHy4PZZnUvxpoz8Xp16HgHfolyaaK0/LfLEvVw 6F1c+BaWnqwJ5b1L6iaY7iQoGysGz1bEb8fVw=
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