This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/46484] [4.5/4.6 Regression] Should reject ALLOCATED(non-variable expression )


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46484

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Target Milestone|---                         |4.6.0
            Summary|Should reject               |[4.5/4.6 Regression] Should
                   |ALLOCATED(non-variable      |reject
                   |expression )                |ALLOCATED(non-variable
                   |                            |expression )

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-11-15 15:25:48 UTC ---
(In reply to comment #1)
> Longer test case is gfortran.dg/allocatable_scalar_5.f90 (cf. 46485).

PR 46485


Mark as 4.5/4.6 regression. It is not true regression as 4.3/4.4 rejected it
with "just" with
  Internal Error at (1):
  gfc_variable_attr(): Expression isn't a variable
but still ...

The reason for the failure is that check.c's variable_check accepts:
   || (e->expr_type == EXPR_FUNCTION

which at a glance does not make sense. Currently, I can only imagine a Fortran
2008 case, which allows pointer-returning functions in place of variables. Cf.
PR 40054 (and PR 46100).

I traced the line back to:
  Rev. 81764: "Merge tree-ssa-20020619-branch into mainline." (2004-05-13)

Thus, it seems as if this line was never valid.

  * * *

Draft patch: The following seems to be sensible and some incomplete regtesting
suggests that it probably works:

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 51ea877..cc36fea 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -491,10 +491,8 @@ variable_check (gfc_expr *e, int n)
       return FAILURE;
     }

-  if ((e->expr_type == EXPR_VARIABLE
+  if (e->expr_type == EXPR_VARIABLE
        && e->symtree->n.sym->attr.flavor != FL_PARAMETER)
-      || (e->expr_type == EXPR_FUNCTION
-         && e->symtree->n.sym->result == e->symtree->n.sym))
     return SUCCESS;

   gfc_error ("'%s' argument of '%s' intrinsic at %L must be a variable",


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]