OSDN Git Service

PR fortran/31266
authortobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Apr 2007 18:10:10 +0000 (18:10 +0000)
committertobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Apr 2007 18:10:10 +0000 (18:10 +0000)
fortran/
* primary.c (gfc_variable_attr): Don't copy string length if it
doesn't make sense.
* resolve.c (resolve_code): Clarify error message.
testsuite/
* gfortran.dg/char_assign_1.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123759 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog

index e99ccd1..ca2721c 100644 (file)
@@ -1,5 +1,10 @@
 2007-04-12  Tobias Schlüter  <tobi@gcc.gnu.org>
 
+       PR fortran/31266
+       * primary.c (gfc_variable_attr): Don't copy string length if it
+       doesn't make sense.
+       * resolve.c (resolve_code): Clarify error message.
+
        PR fortran/31471
        * decl.c (gfc_match_end): Also check for construct name in END
        FORALL and END WERE statements.
index 3044703..1ef37a6 100644 (file)
@@ -1844,7 +1844,14 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
       case REF_COMPONENT:
        gfc_get_component_attr (&attr, ref->u.c.component);
        if (ts != NULL)
-         *ts = ref->u.c.component->ts;
+         {
+           *ts = ref->u.c.component->ts;
+           /* Don't set the string length if a substring reference
+              follows.  */
+           if (ts->type == BT_CHARACTER
+               && ref->next && ref->next->type == REF_SUBSTRING)
+               ts->cl = NULL;
+         }
 
        pointer = ref->u.c.component->pointer;
        allocatable = ref->u.c.component->allocatable;
index f514e77..467ccf4 100644 (file)
@@ -5135,8 +5135,9 @@ resolve_code (gfc_code *code, gfc_namespace *ns)
                rlen = mpz_get_si (code->expr2->ts.cl->length->value.integer);
 
              if (rlen && llen && rlen > llen)
-               gfc_warning_now ("rhs of CHARACTER assignment at %L will be "
-                                "truncated (%d/%d)", &code->loc, rlen, llen);
+               gfc_warning_now ("CHARACTER expression will be truncated "
+                                "in assignment (%d/%d) at %L",
+                                llen, rlen, &code->loc);
            }
 
          if (gfc_pure (NULL))
index 8a40938..2beab78 100644 (file)
@@ -1,5 +1,8 @@
 2007-04-12  Tobias Schlüter  <tobi@gcc.gnu.org>
 
+       PR fortran/31266
+       * gfortran.dg/char_assign_1.f90: New.
+
        PR fortran/31471
        * gfortran.dg/block_name_1.f90: New.
        * gfortran.dg/block_name_2.f90: New.