Skip to content

[Flang] Compilation error of directive (!DIR$ ATTRIBUTES FORCEINLINE) #82212

@ohno-fj

Description

@ohno-fj
Version of flang-new : 19.0.0(730f498c961f29691a605028f9b1cd6d9e232460)

The following is a program with directive (!DIR $ATTRIBUTES FORCEINLINE):

  1. The following is an correct description:
  !DIR$ ATTRIBUTES FORCEINLINE :: sub

flang parses the directive and results in Could not parse error.

  1. The following is an incorrect description:
  !DIR$ ATTRIBUTES FORCEINLINE

flang parses the wrong directive and ignores it.

Because of these behaviors, flang seems to work for this directive.
Therefore, it seems to be a problem that 1. becomes a compilation error.
ifort can compile successfully.
Gfortran seems to consider this directive as a comment line.

The following are the test program, Flang-new, Gfortran and ifort compilation result.

This is the program for 1..
comm_.F:

!DIR$ ATTRIBUTES FORCEINLINE :: sub
      subroutine sub(a,b)
       real(8) :: a,b
        a =0.
        b =1.
      end subroutine sub
$ flang-new comm_.F -c
error: Could not parse comm_.F
./comm_.F:1:30: error: expected end of statement
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
                               ^
./comm_.F:1:1: in the context: specification construct
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:1:1: in the context: declaration construct
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:1:1: in the context: specification part
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:1:1: in the context: main program
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:2:26: error: expected '='
        subroutine sub(a,b)
                           ^
./comm_.F:2:7: in the context: statement function definition
        subroutine sub(a,b)
        ^
./comm_.F:2:7: in the context: declaration construct
        subroutine sub(a,b)
        ^
./comm_.F:1:1: in the context: specification part
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:1:1: in the context: main program
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
./comm_.F:6:11: error: expected end of statement
        end subroutine sub
            ^
./comm_.F:6:7: in the context: END PROGRAM statement
        end subroutine sub
        ^
./comm_.F:1:1: in the context: main program
  !DIR$ ATTRIBUTES FORCEINLINE :: sub
  ^
$
$ gfortran comm_.F -c
$
$ ifort -diag-disable=10448 comm_.F -c
$

This is the program for 2..
comm_2.F:

!DIR$ ATTRIBUTES FORCEINLINE
      subroutine sub(a,b)
       real(8) :: a,b
        a =0.
        b =1.
      end subroutine sub
$ flang-new comm_2.F -c
./comm_2.F:1:2: warning: Compiler directive was ignored
  !DIR$ ATTRIBUTES FORCEINLINE
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
$
$ gfortran comm_2.F -c
$
$ ifort -diag-disable=10448 comm_2.F -c
comm_2.F(1): remark #5082: Directive ignored - Syntax error, found END-OF-STATEMENT when expecting one of: :: , : ]
!DIR$ ATTRIBUTES FORCEINLINE
----------------------------^
$

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:frontend

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions