public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [Committed] PR fortran/44491 -- Select non-NULL locus
Date: Tue, 12 Jun 2018 18:00:00 -0000	[thread overview]
Message-ID: <20180612180008.GA73720@troutmask.apl.washington.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1877 bytes --]

The attached patch has been committed to trunk after
regression testing.  Two loci are available for the
error messages.  If the first locus is NULL, then it
uses the second one to report the error.

In the audit trail of the PR manu@ suggested removing
the assert() that caused the ICE.  His patch tested
for a NULL locus, and simply reported UNKNOWN LOCATION
in the error message.  I find the ICE to be an aid
in locating where gfortran goes sideways, so I've left
the assert() in place.

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 261376)
+++ gcc/fortran/expr.c	(working copy)
@@ -3414,6 +3414,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   /* Only DATA Statements come here.  */
   if (!conform)
     {
+      locus *where;
+
       /* Numeric can be converted to any other numeric. And Hollerith can be
 	 converted to any other type.  */
       if ((gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts))
@@ -3423,8 +3425,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
       if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
 	return true;
 
+      where = lvalue->where.lb ? &lvalue->where : &rvalue->where;
       gfc_error ("Incompatible types in DATA statement at %L; attempted "
-		 "conversion of %s to %s", &lvalue->where,
+		 "conversion of %s to %s", where,
 		 gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts));
 
       return false;
Index: gcc/testsuite/gfortran.dg/pr44491.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr44491.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr44491.f90	(working copy)
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/44491
+      character*2 escape /z'1B'/  { dg-error "Incompatible types in DATA" }
+      end
-- 
Steve

[-- Attachment #2: pr44491.diff --]
[-- Type: text/x-diff, Size: 1378 bytes --]

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 261376)
+++ gcc/fortran/expr.c	(working copy)
@@ -3414,6 +3414,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   /* Only DATA Statements come here.  */
   if (!conform)
     {
+      locus *where;
+
       /* Numeric can be converted to any other numeric. And Hollerith can be
 	 converted to any other type.  */
       if ((gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts))
@@ -3423,8 +3425,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
       if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
 	return true;
 
+      where = lvalue->where.lb ? &lvalue->where : &rvalue->where;
       gfc_error ("Incompatible types in DATA statement at %L; attempted "
-		 "conversion of %s to %s", &lvalue->where,
+		 "conversion of %s to %s", where,
 		 gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts));
 
       return false;
Index: gcc/testsuite/gfortran.dg/pr44491.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr44491.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr44491.f90	(working copy)
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/44491
+      character*2 escape /z'1B'/  ! { dg-error "Incompatible types in DATA" }
+      end

                 reply	other threads:[~2018-06-12 18:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180612180008.GA73720@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).