fortls icon indicating copy to clipboard operation
fortls copied to clipboard

Add support for `STRUCTURE` and `RECORD` blocks vendor extension

Open sdsnatcher opened this issue 3 years ago • 4 comments

Description

fortls seems to be not recognizing structures. We have many of them on a huge legacy code. Here are some an examples:

      Structure /DbTag/
      Integer*4      Name(SZ_TAG)
      Integer*4      Id
      Integer*4      Fnt(SZ_FNT)
      End Structure

      Structure /DbValue/
      Real*4         Value
      Integer*4      Status
      Integer*4      TimeStamp  ! included
      Integer*4      Action
      End Structure

      Structure /MsgValue/
      Integer*4      Mensagem(SZ_MSG)
      Integer*4      Status
      End Structure

And the the following problems are reported by fortls on VSCode:

Unexpected end statement: No open scopes Unexpected end statement: No open scopes Variable "Status" declared twice in scope Unexpected end statement: No open scopes


The same code compiles without issues on gfortran 11.2.0, with the -fdec command line switch.

Expected Behaviour

Should be able to recognize structures. An option to enable -fdec support would be excellent.

Version of Modern Fortran

3.2.0

Version of Visual Studio Code

1.69.0

Platform and Architecture

Windows-10

Additional Information

I have the following linter arguments configured on settings.json:

    "fortran.linter.extraArgs": [
        "-fdec",
        "-finit-local-zero",
        "-fno-underscoring",
        "-Wuninitialized"
      ],

Is there an existing issue for this?

  • [X] I have searched the existing issues

sdsnatcher avatar Jul 12 '22 12:07 sdsnatcher

Originally posted in: https://github.com/fortran-lang/vscode-fortran-support/issues/571

@sdsnatcher As I mentioned in our last conversation I don't see this being implemented unless:

  • it's not intrusive to the rest of the codebase
  • and it's done by a user

Feel free to open a PR and have a try yourself. Here are the instructions for you to get started with contributing to fortls https://github.com/gnikit/fortls/blob/master/CONTRIBUTING.md

You might want to ask in our Discourse group if there are many users affected by this, which in that case I might allocate some time and implement a fix.

gnikit avatar Jul 12 '22 12:07 gnikit

I will have some time to look into this today. I should be able to add structure as an additional scope. I am really not familiar with the STRUCTURE, RECORD syntax, from what I understand is user defined types before TYPE

gnikit avatar Nov 18 '22 07:11 gnikit

Any news on this? Was it possible to implement?

sdsnatcher avatar Aug 02 '23 18:08 sdsnatcher