re PR fortran/30783 ("character(*), value" produces SEGV at runtime)
authorTobias Burnus <burnus@gcc.gnu.org>
Tue, 20 Feb 2007 09:16:58 +0000 (10:16 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Tue, 20 Feb 2007 09:16:58 +0000 (10:16 +0100)
2007-02-20  Tobias Burnus  <burnus@net-b.de>

       PR fortran/30783
       * resolve.c (resolve_symbol): Add character dummy VALUE check.

From-SVN: r122156

gcc/fortran/ChangeLog
gcc/fortran/resolve.c

index 1f2f26ae5dd4e99a177f6f6d159ab91506c3cad3..aac02b9d05c4f26b300014c919a5b1da4ffe1372 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-20  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/30783
+       * resolve.c (resolve_symbol): Add character dummy VALUE check.
+
 2007-02-19  Thomas Koenig  <Thomas.Koenig@online.de>
 
        PR libfortran/30533
@@ -29,8 +34,8 @@
 2007-02-18  Roger Sayle  <roger@eyesopen.com>
            Paul Thomas <pault@gcc.gnu.org>
 
-        PR fortran/30400
-        * match.c (match_forall_iterator): Use gfc_match_expr instead
+       PR fortran/30400
+       * match.c (match_forall_iterator): Use gfc_match_expr instead
        of gfc_match_variable to match the iterator variable.  Return
        MATCH_NO if not a variable.  Remove the reset of the symbol's
        flavor in cleanup.
index 84d42ee34f30b6e849d9be0ef0d668834d168c75..8db36b5f2c0e1321736c7809c11824fe33a2d065 100644 (file)
@@ -6153,10 +6153,22 @@ resolve_symbol (gfc_symbol *sym)
   if (sym->attr.value && !sym->attr.dummy)
     {
       gfc_error ("'%s' at %L cannot have the VALUE attribute because "
-                "it is not a dummy", sym->name, &sym->declared_at);
+                "it is not a dummy argument", sym->name, &sym->declared_at);
       return;
     }
 
+  if (sym->attr.value && sym->ts.type == BT_CHARACTER)
+    {
+      gfc_charlen *cl = sym->ts.cl;
+      if (!cl || !cl->length || cl->length->expr_type != EXPR_CONSTANT)
+       {
+         gfc_error ("Character dummy variable '%s' at %L with VALUE "
+                    "attribute must have constant length",
+                    sym->name, &sym->declared_at);
+         return;
+       }
+    }
+
   /* If a derived type symbol has reached this point, without its
      type being declared, we have an error.  Notice that most
      conditions that produce undefined derived types have already