[PATCH] Tighten up checks for ASSIGN statement

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Mon Dec 6 00:13:00 GMT 2004


I ran into this when looking into PR 18827: we accepted ASSIGN statements of
the form
  ASSIGN 1000 TO I
where I is an array of integers.  Actually, we allowed general expressions as
long as they're of type integer.

This patch tightens stuff up, the standard only allows a scalar-int-variable,
with the variable being of default kind and this is enforced by this patch. I
will add the attached testcase to the testsuite, patch below.

Bubblestrapped and tested on i686-pc-linux. OK?

- Tobi

2004-12-05  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	* resolve.c (resolve_code): Impose correct restrictions on ASSIGN
	statement.

Index: resolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.21
diff -u -p -r1.21 resolve.c
--- resolve.c   8 Nov 2004 14:56:39 -0000       1.21
+++ resolve.c   6 Dec 2004 00:10:28 -0000
@@ -3678,9 +3678,15 @@ resolve_code (gfc_code * code, gfc_names
           if (code->label->defined == ST_LABEL_UNKNOWN)
             gfc_error ("Label %d referenced at %L is never defined",
                        code->label->value, &code->label->where);
-          if (t == SUCCESS && code->expr->ts.type != BT_INTEGER)
-           gfc_error ("ASSIGN statement at %L requires an INTEGER "
-                      "variable", &code->expr->where);
+          if (t == SUCCESS
+             && (code->expr->expr_type != EXPR_VARIABLE
+                 || code->expr->symtree->n.sym->ts.type != BT_INTEGER
+                 || code->expr->symtree->n.sym->ts.kind
+                       != gfc_default_integer_kind
+                 || code->expr->symtree->n.sym->as != NULL))
+           gfc_error ("ASSIGN statement at %L requires a scalar "
+                      "INTEGER*%d variable",
+                      &code->expr->where, gfc_default_integer_kind);
          break;

        case EXEC_POINTER_ASSIGN:


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: assign_1.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041206/03191089/attachment.f90>


More information about the Gcc-patches mailing list