Import statement needs new glasses

Import statement needs new glasses

With the recent release I'm seeing an oddity with the import statement being unable to find things in the host scope, under certain specific conditions, that looks a bit dodgy. 

MODULE StNodes
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: AddNode
  !-----------------------------------------------------------------------------
  TYPE, PUBLIC :: StNode      ! Type StNode is a public entity.
    CLASS(StNode), POINTER :: parent => NULL()
  END TYPE StNode
  
  TYPE, PUBLIC :: StNodeList
    CLASS(StNode), ALLOCATABLE :: item
  END TYPE StNodeList
  !-----------------------------------------------------------------------------
  INTERFACE AddNode 
    MODULE PROCEDURE AddNode_
  END INTERFACE AddNode
CONTAINS
  SUBROUTINE AddNode_(list)
    TYPE(StNodeList), INTENT(INOUT), ALLOCATABLE :: list(:)
    !***************************************************************************
    IF (ALLOCATED(list)) CONTINUE     ! Avoid "not used" warning.
  END SUBROUTINE AddNode_
END MODULE StNodes
MODULE ExecStNodes
  USE StNodes       ! This makes all public entities of StNodes accessible.
                    ! (which should include StNode).
  IMPLICIT NONE
  PRIVATE
  
  TYPE, PUBLIC, ABSTRACT, EXTENDS(StNode) :: ExecStNode
    TYPE(StNodeList), ALLOCATABLE :: statements(:)
  END TYPE ExecStNode
  
  INTERFACE
    SUBROUTINE ExecStNodeFactory(ist, node)
      ! StNode should be accessible in host, but error #6483 here.
      IMPORT :: StNode
      IMPLICIT NONE
      !-------------------------------------------------------------------------
      INTEGER, INTENT(IN) :: ist
      CLASS(StNode), INTENT(OUT), ALLOCATABLE :: node
    END SUBROUTINE ExecStNodeFactory
  END INTERFACE
CONTAINS
  RECURSIVE SUBROUTINE exec_BuildTree
    CLASS(ExecStNode), ALLOCATABLE :: st
    !***************************************************************************
    CALL AddNode(st%statements)
  END SUBROUTINE exec_BuildTree
END MODULE ExecStNodes

>ifort /c /check:all /warn:all /standard-semantics ExecStNodes.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.103 Build 20130728
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.
ExecStNodes.f90(38): error #6483: IMPORT-name must be the name of an entity in the host scoping unit   [STNODE]
      IMPORT :: StNode
----------------^
ExecStNodes.f90(42): error #6457: This derived type name has not been declared.   [STNODE]
      CLASS(StNode), INTENT(OUT), ALLOCATABLE :: node
------------^
ExecStNodes.f90(36): error #6404: This name does not have a type, and must have an explicit type.   [NODE]
    SUBROUTINE ExecStNodeFactory(ist, node)
--------------------------------------^
compilation aborted for ExecStNodes.f90 (code 1)

The workaround is simple enough - just USE the module.

The 14.0 release seems reasonably robust so far.  It looks like keeping my bedroom clean paid off!

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Escalated as DPD200247835. Thanks. The PRIVATE/PUBLIC doesn't matter here, I found.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today