OCamlPro / gnucobol

A clone of the sourceforge GnuCOBOL compiler from COBOL to C.
https://get-superbol.com
GNU Lesser General Public License v3.0
16 stars 20 forks source link

New flag -fdiagnostics-absolute-path to display full paths within err… #112

Closed lefessan closed 6 months ago

lefessan commented 10 months ago

…or locations

This flag is useful for editors that cannot correctly locate files with recursive build systems (typically, vscode running make to compile a gnucobol project)

GitMensch commented 10 months ago

How is the flag called by gcc and/or clang?

Note: a "plain" filename like "mycopy.cpy" should be resovlved in vscode by opening that file from the workspace; relative names will work (depending on the absolute/relative setting, the later taking the cwd/env you use for the task into account). A real problem starts if you have the same name in multiple places and one of the paths specified with -I is used. .. but then: wouldn't it be more reasonable to directly use the pathname as it was used on open (with no extra flag)?

This can also (with relative paths) be tested then.

lefessan commented 10 months ago

gcc does not have this option, but clang has:

  -fdiagnostics-absolute-paths
                          Print absolute paths in diagnostics

Just a s to add...

For vscode, my experience is that, using the GnuCOBOL extension and problem matchers, and a project with a hierarchy of Makefiles, vscode was unable to correctly locate the files where the errors happened. It worked after adding this option.

GitMensch commented 10 months ago

Please give a sample compile with / without this flag.

lefessan commented 10 months ago

Without:

$ cobc -g --free -I copy/ -x -o 01_generate.exe 01_generate.cob
01_generate.cob:3: error: ENVIRONMENT DIVISION header missing
    1 | IDENTIFICATION DIVISION.
    2 | PROGRAM-ID. 01_generate.
    3 > x
    4 | ENVIRONMENT DIVISION.
    5 | 

With:

$ cobc -g --free -fdiagnostics-absolute-paths -I copy/ -x -o 01_generate.exe 01_generate.cob
/home/lefessan/GIT/COBOL/cobol-project/src/01_generate.cob:3: error: ENVIRONMENT DIVISION header missing
    1 | IDENTIFICATION DIVISION.
    2 | PROGRAM-ID. 01_generate.
    3 > x
    4 | ENVIRONMENT DIVISION.
    5 | 
GitMensch commented 10 months ago

I think I see where the issue is (executing a recursive make, right?)

Please add a copybook that has a warning and is found in the copy folder.

lefessan commented 10 months ago
cobc -g --free -fdiagnostics-absolute-path -I copy/ -x -o 01_generate.exe 01_generate.cob
/home/lefessan/GIT/COBOL/cobol-project/src/copy/integer-string.cpy:1: error: RECORD description missing or invalid
    1 > x
    2 | 01 :FILE:-REC.
    3 | 05 :FILE:-REC-INT PIC 9(5).
GitMensch commented 10 months ago

What's the output with the unpatched version?

Is the problem a "make" that uses sub-folders?

lefessan commented 10 months ago

The patch only modifies the behavior for relative paths, by adding the current working directory in front of it, and then checking whether such a file really exists. So, it will only modify the display in the cases where the display caret would work.

cobc -g --free -I copy/ -x -o 01_generate.exe 01_generate.cob [18:27]

copy/integer-string.cpy:1: error: RECORD description missing or invalid
    1 > x
    2 | 01 :FILE:-REC.
    3 | 05 :FILE:-REC-INT PIC 9(5).

Yes, my initial problem with vscode was using make in sub-folders, but this feature could be useful in the future for any editor having the same problem, even if it is fixed in vscode.

GitMensch commented 10 months ago

The biggest issue I have is that we cannot add it reasonable to the automated test suite, can we? If not then it may still be reasonable to add it to the manual testsuite...

codecov-commenter commented 10 months ago

Codecov Report

Merging #112 (17dc9d6) into gcos4gnucobol-3.x (c0d64ad) will increase coverage by 0.00%. The diff coverage is 66.66%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@                Coverage Diff                 @@
##           gcos4gnucobol-3.x     #112   +/-   ##
==================================================
  Coverage              65.74%   65.74%           
==================================================
  Files                     32       32           
  Lines                  59092    59110   +18     
  Branches               15575    15583    +8     
==================================================
+ Hits                   38849    38861   +12     
  Misses                 14262    14262           
- Partials                5981     5987    +6     
Files Coverage Δ
cobc/cobc.c 72.39% <ø> (ø)
cobc/flag.def 100.00% <100.00%> (ø)
cobc/error.c 73.78% <64.70%> (-0.27%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

lefessan commented 9 months ago

I am adding some documentation in gnucobol.texi, and I have a question:

Shouldn't -fdiagnostics-plain-output also imply -fno-diagnostics-show-option ?

GitMensch commented 9 months ago

Shouldn't -fdiagnostics-plain-output also imply -fno-diagnostics-show-option ?

Only if it is included with GCC, my understanding is that this isn't the case as the later only got introduced after the former (at least this is the way it was with GC). Please recheck to know.