From: Thomas Koenig <tkoenig@netcologne.de>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch, fortran] Fix PR 86111, ICE on invalid
Date: Sat, 06 Oct 2018 17:53:00 -0000 [thread overview]
Message-ID: <5dc538d0-870d-0596-fa34-f2d71fdeeda1@netcologne.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 715 bytes --]
Hello world,
the attached patch fixes an ICE regression by issuing an error
when a clever combination of array constructors ends up
in gfc_arith_concat with mismatched types, before resultion
has a chance to report the error.
Regression-tested. OK for trunk?
Regards
Thomas
2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86111
* gfortran.h (enum arith): Add ARITH_WRONGCONCAT.
* arith.h (gfc_arith_error): Issue error for ARITH_WRONGCONCAT.
(gfc_arith_concat): If the types of op1 and op2 are not
character of if their kinds do not match, issue ARITH_WRONGCONCAT.
2018-10-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/86111
* gfortran.dg/array_constructor_type_23.f90: New test.
[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 1455 bytes --]
Index: arith.c
===================================================================
--- arith.c (Revision 264897)
+++ arith.c (Arbeitskopie)
@@ -113,6 +113,11 @@ gfc_arith_error (arith code)
p =
_("Integer outside symmetric range implied by Standard Fortran at %L");
break;
+ case ARITH_WRONGCONCAT:
+ p =
+ _("Illegal type in character concatenation at %L");
+ break;
+
default:
gfc_internal_error ("gfc_arith_error(): Bad error code");
}
@@ -982,7 +987,12 @@ gfc_arith_concat (gfc_expr *op1, gfc_expr *op2, gf
gfc_expr *result;
size_t len;
- gcc_assert (op1->ts.kind == op2->ts.kind);
+ /* By cleverly playing around with constructors, is is possible
+ to get mismaching types here. */
+ if (op1->ts.type != BT_CHARACTER || op2->ts.type != BT_CHARACTER
+ || op1->ts.kind != op2->ts.kind)
+ return ARITH_WRONGCONCAT;
+
result = gfc_get_constant_expr (BT_CHARACTER, op1->ts.kind,
&op1->where);
Index: gfortran.h
===================================================================
--- gfortran.h (Revision 264897)
+++ gfortran.h (Arbeitskopie)
@@ -191,7 +191,8 @@ enum gfc_intrinsic_op
/* Arithmetic results. */
enum arith
{ ARITH_OK = 1, ARITH_OVERFLOW, ARITH_UNDERFLOW, ARITH_NAN,
- ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT
+ ARITH_DIV0, ARITH_INCOMMENSURATE, ARITH_ASYMMETRIC, ARITH_PROHIBIT,
+ ARITH_WRONGCONCAT
};
/* Statements. */
[-- Attachment #3: array_constructor_type_23.f90 --]
[-- Type: text/x-fortran, Size: 217 bytes --]
! { dg-do compile }
! PR 83999 - this used to ICE
! Origial test case by Gerhard Steinmetz
program p
character(2) :: c = 'a' // [character :: [1]] ! { dg-error "Illegal type in character concatenation" }
end
next reply other threads:[~2018-10-06 17:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-06 17:53 Thomas Koenig [this message]
2018-10-06 17:58 ` Jerry DeLisle
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=5dc538d0-870d-0596-fa34-f2d71fdeeda1@netcologne.de \
--to=tkoenig@netcologne.de \
--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).