public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/46484] [4.5/4.6 Regression] Should reject ALLOCATED(non-variable expression )
Date: Mon, 15 Nov 2010 15:38:00 -0000	[thread overview]
Message-ID: <bug-46484-4-XnEtww7KwL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-46484-4@http.gcc.gnu.org/bugzilla/>

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",


  parent reply	other threads:[~2010-11-15 15:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-15 14:49 [Bug fortran/46484] New: " burnus at gcc dot gnu.org
2010-11-15 14:55 ` [Bug fortran/46484] " burnus at gcc dot gnu.org
2010-11-15 15:38 ` burnus at gcc dot gnu.org [this message]
2010-11-15 17:31 ` [Bug fortran/46484] [4.5/4.6 Regression] " kargl at gcc dot gnu.org
2010-11-15 18:08 ` burnus at gcc dot gnu.org
2010-11-15 20:48 ` burnus at gcc dot gnu.org
2010-11-15 21:04 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-46484-4-XnEtww7KwL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).