Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Bindings of types local to procedures can't find module procedures

$
0
0

If you have a module procedure that is explicitly marked PUBLIC, and you try and use that procedure for a binding for a type definition that is local to another procedure, then current ifort complains that the name of the module procedure doesn't have an explicit interface.

Delete the PUBLIC statement for the procedure in the specification part of the module, and all is well...

MODULE m
  IMPLICIT NONE
  PUBLIC :: True
  PUBLIC :: False      !<<<< Delete this and things work.

  TYPE, PUBLIC :: TraitsType
  CONTAINS
    PROCEDURE, NOPASS :: XYZ => True
  END TYPE TraitsType

  TYPE, PUBLIC :: Thing
    CLASS(TraitsType), ALLOCATABLE :: traits
  END TYPE Thing
CONTAINS
  SUBROUTINE proc(arg)
    TYPE(Thing), INTENT(OUT) :: arg

    TYPE, EXTENDS(TraitsType) :: local_traits
    CONTAINS
      PROCEDURE, NOPASS :: XYZ => False
    END TYPE local_traits

    ALLOCATE(arg%traits, SOURCE=local_traits())
  END SUBROUTINE proc

  FUNCTION True() RESULT(b)
    LOGICAL :: b
    b = .TRUE.
  END FUNCTION True

  FUNCTION False() RESULT(b)
    LOGICAL :: b
    b = .FALSE.
  END FUNCTION False
END MODULE m

 

>ifort /check:all /warn:all /standard-semantics "2015-09-07 true.f90"
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0 Build 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

2015-09-07 true.f90(20): error #8182: The name is neither an abstract interface nor a procedure with an explicit interface.   [FALSE]
      PROCEDURE, NOPASS :: XYZ => False
----------------------------------^
compilation aborted for 2015-09-07 true.f90 (code 1)

The mention of abstract interface in the error message is odd, as the syntax does not permit the name of an abstract interface to be used as the procedure name in a type bound procedure statement.

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>