public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH,committed] PR fortran/51993 -- Convert assert() to if-statement
@ 2015-10-30 18:29 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2015-10-30 18:29 UTC (permalink / raw)
  To: fortran, gcc-patches

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

I've committed the attached patch as obvious.  It
converts a gcc_assert() into an if-statement, which
then allows gfortran to issue a sensible error
message.

2015-10-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/51993
	* decl.c (gfc_set_constant_character_len): Convert gcc_assert into an
	if-statement causing an early return leads to valid error message.

2015-10-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/51993
	* gfortran.dg/pr51993.f90: New test.

-- 
Steve

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

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 229593)
+++ gcc/fortran/decl.c	(working copy)
@@ -1293,7 +1293,9 @@ gfc_set_constant_character_len (int len,
   int slen;
 
   gcc_assert (expr->expr_type == EXPR_CONSTANT);
-  gcc_assert (expr->ts.type == BT_CHARACTER);
+
+  if (expr->ts.type != BT_CHARACTER)
+    return;
 
   slen = expr->value.character.length;
   if (len != slen)
Index: gcc/testsuite/gfortran.dg/pr51993.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr51993.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr51993.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/51993
+! Code contributed by Sebastien Bardeau <bardeau at iram dot fr>
+module mymod
+  type :: mytyp
+    character(len=3) :: a = .true. ! { dg-error "convert LOGICAL" }
+  end type mytyp
+end module mymod

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-30 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 18:29 [PATCH,committed] PR fortran/51993 -- Convert assert() to if-statement Steve Kargl

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).