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  <ka...@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  <ka...@gcc.gnu.org>

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

-- 
Steve
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

Reply via email to