This is the mail archive of the gcc-patches@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]

[PATCH] Fix PR fortran/19926


The attached patch fixes PR fortran/19926.  The problem
is easiest to explain by looking at the snippet of code
from the PR.

subroutine string_comp(i)
   integer, parameter :: map(0:50) = 3
   integer :: i
   i = map(42)
end subroutine string_comp

The problem lies in primary.c:gfc_match_rvalue() where we are
parsing/resolving a PARAMETER expression.  The above parameter
sets sym->value->expr_type = EXPR_CONSTANT, so a branch of an
if statement that test (sym->value->expr_type != EXPR_ARRAY)
because expr_type cannot simultaneous be EXPR_CONSTANT and
EXPR_ARRAY.  To get to the else portion of the test we
can check if sym->as is non-NULL, which indicates that we have
an array with constant content.

Hopefully, the above makes sense, and the patch does the
right thing.

Bootstrapped and regression tested on i386-*-freebsd.
There are no new regressions with this patch.

Erik found the location of bug and provided the initial
patch.  I've changed the patch to the current stated.

2005-06-12  Erik Edelman  <eedelman@acclab.helsinki.fi>
            Steven G. Kargl <kargls@comast.net>

    PR fortran/19926
	* primary.c (gfc_match_rvalue):  expr_type can be EXPR_CONSTANT
	for an array; check that sym->as is NULL.

-- 
Steve

Attachment: primary.c.diff
Description: Text document

Attachment: pr19926.f90
Description: Text document


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