Hello world,

I just adjusted the error message for BIND(C) functions which
return strings of length > 1.  I just used the suggestion from
the PR.  Committed as obvious and simple (although I managed
to use up three revisions to do it right :-)

Regards

        Thomas

2018-11-01  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/46020
        * decl.c (verify_bind_c_sym): Improve error message.

2018-11-01  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/46020
        * gfortran.dg/bind_c_usage_7.f90: Adjust error message.
        * gfortran.dg/bind_c_usage_32.f90: New test.
Index: decl.c
===================================================================
--- decl.c	(Revision 265502)
+++ decl.c	(Arbeitskopie)
@@ -5647,8 +5647,8 @@ verify_bind_c_sym (gfc_symbol *tmp_sym, gfc_typesp
 	if (tmp_sym->ts.u.cl == NULL || tmp_sym->ts.u.cl->length == NULL
 	    || tmp_sym->ts.u.cl->length->expr_type != EXPR_CONSTANT
 	    || mpz_cmp_si (tmp_sym->ts.u.cl->length->value.integer, 1) != 0)
-	  gfc_error ("Return type of BIND(C) function %qs at %L cannot "
-			 "be a character string", tmp_sym->name,
+	  gfc_error ("Return type of BIND(C) function %qs of character "
+		     "type at %L must have length 1 ", tmp_sym->name,
 			 &(tmp_sym->declared_at));
     }
 
Index: bind_c_usage_7.f03
===================================================================
--- bind_c_usage_7.f03	(Revision 265715)
+++ bind_c_usage_7.f03	(Arbeitskopie)
@@ -7,7 +7,7 @@ contains
     integer(c_int) :: bar(5)
   end function bar
 
-  function my_string_func() bind(c) ! { dg-error "cannot be a character string" }
+  function my_string_func() bind(c) ! { dg-error "must have length 1" }
     character(kind=c_char, len=10) :: my_string_func
     my_string_func = 'my_string' // C_NULL_CHAR
   end function my_string_func
Index: bind_c_usage_32.f90
===================================================================
--- bind_c_usage_32.f90	(nicht existent)
+++ bind_c_usage_32.f90	(Revision 265717)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR 46020 - check for clear error message
+! { dg-options "" }
+FUNCTION F_X(A) bind(c,name='F_X') ! { dg-error "must have length 1" }
+   CHARACTER*(*) F_X
+END FUNCTION
+
+
+FUNCTION F_Y(A) bind(c,name='F_Y') ! { dg-error "must have length 1" }
+   CHARACTER*(2) F_Y
+END FUNCTION
+
+

Reply via email to