Bug 17911 - ice: wrongly resolved ambguity between generic function and local variable
Summary: ice: wrongly resolved ambguity between generic function and local variable
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2004-10-09 13:57 UTC by Tobias Schlüter
Modified: 2006-01-30 12:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-27 20:35:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schlüter 2004-10-09 13:57:53 UTC
[tobi@marktplatz tests]$ cat generic.f90
module t
  interface a
     module procedure b
  end interface
contains
  integer function b(x)
    b = x
  end function b
end module t

subroutine r
  use t

  b = 1.
  y = a(1.)
end subroutine r
[tobi@marktplatz tests]$ ~/src/gcc/build-clean/gcc/f951 generic.f90
 b
 r

generic.f90:11: internal compiler error: in gfc_conv_variable, at
/fortran/trans-expr.c:319
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

From -fdump-parse-tree (namespace dump for subroutine r):
        Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
        procedure name = r
        symtree: y  Ambig 0
        symbol y (REAL 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC
IMPLICIT-TYPE)

        symtree: a  Ambig 0
        symbol a (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC)
        Generic interfaces: b

        symtree: b  Ambig 0
        symbol b (INTEGER 4)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS MODULE-PROC
USE-ASSOC FUNCTION)
        result: b
        Formal arglist: x
        Formal namespace
          Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
          procedure name = b
          symtree: @0  Ambig 0
          symbol x (REAL 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC
DUMMY USE-ASSOC)

        symtree: r  Ambig 0
        symbol r (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC SUBROUTINE)

        symtree: t  Ambig 0
        symbol t (UNKNOWN 0)(MODULE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC
USE-ASSOC)


      ASSIGN b 1
      ASSIGN y __convert_i4_r4[[((b[[((1.000000))]]))]]

 r

There's only one symbol b, and apparently no difference is made between them.

The assertion is:
299:  sym = expr->symtree->n.sym;
300:  if (se->ss != NULL)
301:    {
...
311:   else
312:    {
...
316:      if (sym->attr.flavor == FL_PROCEDURE
317:	      && se->expr != current_function_decl)
318:	    {
319:	      gcc_assert (se->want_pointer); /////////// HERE

So it tries to deal with a procedure symbol as if it were a variable, which
supports the previous analysis
Comment 1 Tobias Schlüter 2004-10-09 14:35:34 UTC
This is invalid code. If b is declared private gfortran does the right thing.
Comment 2 Andrew Pinski 2004-10-09 18:35:27 UTC
confirmed.
Comment 3 Paul Thomas 2006-01-29 06:08:12 UTC
Subject: Bug 17911

Author: pault
Date: Sun Jan 29 06:08:07 2006
New Revision: 110365

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110365
Log:
2006-01-28  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/17911
	* expr.c (gfc_check_assign, gfc_check_pointer_assign): Emit error if
	the lvalue is a use associated procedure.

	PR fortran/20895
	PR fortran/25030
	* expr.c (gfc_check_pointer_assign): Emit error if lvalue and rvalue
	character lengths are not the same.  Use gfc_dep_compare_expr for the
	comparison.
	* gfortran.h: Add prototype for gfc_dep_compare_expr.
	* dependency.h: Remove prototype for gfc_dep_compare_expr.

2006-01-29  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/17911
	* gfortran.dg/procedure_lvalue.f90: New test.

	PR fortran/20895
	PR fortran/25030
	* gfortran.dg/char_pointer_assign_2.f90: New test.
	* gfortran.dg/char_result_1.f90: Correct unequal charlen pointer
	assignment to be consistent with standard.
	* gfortran.dg/char_result_2.f90: The same.
	* gfortran.dg/char_result_8.f90: The same.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_pointer_assign_2.f90
    trunk/gcc/testsuite/gfortran.dg/procedure_lvalue.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.h
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/char_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/char_result_2.f90
    trunk/gcc/testsuite/gfortran.dg/char_result_8.f90

Comment 4 Paul Thomas 2006-01-30 05:45:23 UTC
Subject: Bug 17911

Author: pault
Date: Mon Jan 30 05:45:06 2006
New Revision: 110394

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110394
Log:
2006-01-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/18578
	PR fortran/18579
	PR fortran/20857
	PR fortran/20885
	* interface.c (compare_actual_formal): Error for INTENT(OUT or INOUT)
	if actual argument is not a variable.

	PR fortran/17911
	* expr.c (gfc_check_assign, gfc_check_pointer_assign): Emit error if
	the lvalue is a use associated procedure.

	PR fortran/20895
	PR fortran/25030
	* expr.c (gfc_check_pointer_assign): Emit error if lvalue and rvalue
	character lengths are not the same.  Use gfc_dep_compare_expr for the
	comparison.
	* gfortran.h: Add prototype for gfc_dep_compare_expr.
	* dependency.h: Remove prototype for gfc_dep_compare_expr.

2006-01-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/18578
	PR fortran/18579
	PR fortran/20857
	PR fortran/20885
	* gfortran.dg/intent_out_1.f90: New test.

	PR fortran/17911
	* gfortran.dg/procedure_lvalue.f90: New test.

	PR fortran/20895
	PR fortran/25030
	* gfortran.dg/char_pointer_assign_2.f90: New test.
	* gfortran.dg/char_result_1.f90: Correct unequal charlen pointer
	assignment to be consistent with standard.
	* gfortran.dg/char_result_2.f90: The same.
	* gfortran.dg/char_result_8.f90: The same.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_pointer_assign_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intent_out_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/procedure_lvalue.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/dependency.h
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/gfortran.h
    branches/gcc-4_1-branch/gcc/fortran/interface.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_8.f90

Comment 5 Paul Thomas 2006-01-30 05:50:56 UTC
Fixed on trunk and 4.1.

Paul