llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang] Update the fix of PR #80738 to get the ultimate symbol

Open DanielCChen opened this issue 2 years ago • 3 comments

The following test cases crashes. The problem is that the fix for PR #80738 is not quite complete. It should GetUltimate() of the interface_ before check if it is generic.

  MODULE M

    CONTAINS

    FUNCTION Int(Arg)
    INTEGER :: Int, Arg
      Int = Arg
    END FUNCTION

    FUNCTION Int8(Arg)
    INTEGER(8) :: Int8, Arg
      Int8 = 8_8
    END FUNCTION

  END MODULE

  MODULE M1
  USE M

    INTERFACE Int8
      MODULE PROCEDURE  Int
      MODULE PROCEDURE  Int8
    END INTERFACE

  END MODULE

  PROGRAM PtrAssignGen
  USE M
  USE M1
  IMPLICIT NONE

  INTERFACE Int
    MODULE PROCEDURE  Int
    MODULE PROCEDURE  Int8
  END INTERFACE

  PROCEDURE(Int8),   POINTER :: PtrInt8

  PtrInt8 => Int8
  IF ( PtrInt8(100_8) .NE. 8_8 ) ERROR STOP 12

  END

DanielCChen avatar Feb 07 '24 18:02 DanielCChen

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

The following test cases crashes. The problem is when procedure pointer `PtrInt8` is declared, its `procInterface` `Int8` is not marked as generic nor specific function, so it is typeless.

The -fdebug-dump-symbols shows int8 (Function): Use from int8 in m1.

  Module scope: m size=0 alignment=1 sourceRange=156 bytes
    int, PUBLIC (Function): Subprogram result:INTEGER(4) int (INTEGER(4) arg)
    int8, PUBLIC (Function): Subprogram result:INTEGER(8) int8 (INTEGER(8) arg)
    Subprogram scope: int size=8 alignment=4 sourceRange=60 bytes
      arg size=4 offset=4: ObjectEntity dummy type: INTEGER(4)
      int size=4 offset=0: ObjectEntity funcResult type: INTEGER(4)
    Subprogram scope: int8 size=16 alignment=8 sourceRange=66 bytes
      arg size=8 offset=8: ObjectEntity dummy type: INTEGER(8)
      int8 size=8 offset=0: ObjectEntity funcResult type: INTEGER(8)
  Module scope: m1 size=0 alignment=1 sourceRange=98 bytes
    int, PUBLIC (Function): Use from int in m
    int8, PUBLIC (Function): Generic Name (specific) procs: int,int8
  MainProgram scope: ptrassigngen size=8 alignment=8 sourceRange=216 bytes
    int (Function): Generic Name (specific) procs: int,int8
    int8 (Function): Use from int8 in m1
    ptrint8, EXTERNAL, POINTER (Function) size=8 offset=0: ProcEntity int8

I would expect both Int and Int8 are generic names that has specific Int and Int8 from module m.

  MODULE M

    CONTAINS

    FUNCTION Int(Arg)
    INTEGER :: Int, Arg
      Int = Arg
    END FUNCTION

    FUNCTION Int8(Arg)
    INTEGER(8) :: Int8, Arg
      Int8 = 8_8
    END FUNCTION

  END MODULE

  MODULE M1
  USE M

    INTERFACE Int8
      MODULE PROCEDURE  Int
      MODULE PROCEDURE  Int8
    END INTERFACE

  END MODULE

  PROGRAM PtrAssignGen
  USE M
  USE M1
  IMPLICIT NONE

  INTERFACE Int
    MODULE PROCEDURE  Int
    MODULE PROCEDURE  Int8
  END INTERFACE

  PROCEDURE(Int8),   POINTER :: PtrInt8

  PtrInt8 => Int8
  IF ( PtrInt8(100_8) .NE. 8_8 ) ERROR STOP 12

  END

llvmbot avatar Feb 07 '24 18:02 llvmbot

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

The following test cases crashes. The problem is when procedure pointer `PtrInt8` is declared, its `procInterface` `Int8` is not marked as generic nor specific function, so it is typeless.

The -fdebug-dump-symbols shows int8 (Function): Use from int8 in m1.

  Module scope: m size=0 alignment=1 sourceRange=156 bytes
    int, PUBLIC (Function): Subprogram result:INTEGER(4) int (INTEGER(4) arg)
    int8, PUBLIC (Function): Subprogram result:INTEGER(8) int8 (INTEGER(8) arg)
    Subprogram scope: int size=8 alignment=4 sourceRange=60 bytes
      arg size=4 offset=4: ObjectEntity dummy type: INTEGER(4)
      int size=4 offset=0: ObjectEntity funcResult type: INTEGER(4)
    Subprogram scope: int8 size=16 alignment=8 sourceRange=66 bytes
      arg size=8 offset=8: ObjectEntity dummy type: INTEGER(8)
      int8 size=8 offset=0: ObjectEntity funcResult type: INTEGER(8)
  Module scope: m1 size=0 alignment=1 sourceRange=98 bytes
    int, PUBLIC (Function): Use from int in m
    int8, PUBLIC (Function): Generic Name (specific) procs: int,int8
  MainProgram scope: ptrassigngen size=8 alignment=8 sourceRange=216 bytes
    int (Function): Generic Name (specific) procs: int,int8
    int8 (Function): Use from int8 in m1
    ptrint8, EXTERNAL, POINTER (Function) size=8 offset=0: ProcEntity int8

I would expect both Int and Int8 are generic names that has specific Int and Int8 from module m.

  MODULE M

    CONTAINS

    FUNCTION Int(Arg)
    INTEGER :: Int, Arg
      Int = Arg
    END FUNCTION

    FUNCTION Int8(Arg)
    INTEGER(8) :: Int8, Arg
      Int8 = 8_8
    END FUNCTION

  END MODULE

  MODULE M1
  USE M

    INTERFACE Int8
      MODULE PROCEDURE  Int
      MODULE PROCEDURE  Int8
    END INTERFACE

  END MODULE

  PROGRAM PtrAssignGen
  USE M
  USE M1
  IMPLICIT NONE

  INTERFACE Int
    MODULE PROCEDURE  Int
    MODULE PROCEDURE  Int8
  END INTERFACE

  PROCEDURE(Int8),   POINTER :: PtrInt8

  PtrInt8 => Int8
  IF ( PtrInt8(100_8) .NE. 8_8 ) ERROR STOP 12

  END

llvmbot avatar Feb 07 '24 18:02 llvmbot

https://github.com/llvm/llvm-project/pull/81087

DanielCChen avatar Feb 08 '24 04:02 DanielCChen