-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -fdiagnostics-show-caret to display the context of an error #85
Add -fdiagnostics-show-caret to display the context of an error #85
Conversation
As an example:
|
Note that the default is currently to disable this feature, but it could be activated by default (and disabled through |
Hm, the idea is good and the general point of reworking the diagnostic format is even on the GSOC idea list for GnuCOBOL (did you get it from there/the note on the dev list about that?).
But reading the source file again should be absolute last resort and will be very likely wrong for REPLACE/REPLACING and won't work for complies from stdin.
So... Could you please rework that to possibly save the context from the scanner via to a static buffer?
Also note that -fno-diagnostics-show-line-numbers should be added along with this change (which would drop the leading line numbers) and possibly -fdiagnostics-show-caret should be used to toggle this instead of -fpreview-error ... and ideally we should also use the caret to show where the error is.
As a general rule of thumb we'd like to reach https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html ...
someday.
|
2489f74
to
0218831
Compare
No, I didn't know about the GSOC idea. Is it discussed on the forum ?
I won't be able to spend much more time on this patch. For now, I changed the name of the option to
Would it be ok to merge this work as it is, and wait for the GSOC to get it improved ? I will be working on adding a bit more GCOS support now, so I won't be able to improve this patch more before some time. |
@GitMensch Hi, I say on the forum that you mentioned this patch. Do you think it would be ok to merge it in the current state ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GitMensch Hi, I've seen on the forum that you mentioned this patch. Do you think it would be ok to merge it in the current state ?
Not in its current state :-/ But after reviewing the initial GCC implementation (also opened the file then read and print the lines), I'm now open to add it without the design change I previously thought of (GCC did that later on).
Things that are likely easy to do:
- drop
COBC_DIAGNOSTICS_SHOW_CARET
completely; for the testsuite it is enough to add-fno-diagnostics-show-caret
in tests/atlocal.in, just as I did with-fno-diagnostics-show-option
- rebase
- add
-fno-diagnostics-show-line-numbers
(because it is just a single flag that only modifies the output in one place) - add an entry in NEWS and doc/gnucobol.tex about the two new options
Then, as a follow up, we may use source caches, like the current GCC implementation does.
But still you may want to have a look at the old diagnostic print function linked before your commit and look for good style; and have a look at the current one
0218831
to
2537121
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly ready now - see review details.
friendly ping @lefessan |
e03b474
to
68f3b68
Compare
I think all your requests have been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only minor changes needed (feel free to directly commit)
If you want to finish that completely, then add -fdiagnostics-plain-output
to cobc.c (this is a "normal" option, no flag, it has no "no" and would set both new options to ´0`) and use this in tests/atlocal.in for the flags and add it in the NEWS - otherwise I'll do that after your commit.
Possibly use in the NEWS something similar to GCCs entry: the diagnostics now print the source code context with a left margin showing line numbers, configurable with -fno-diagnostics-show-line-numbers, and possible to disable completely with -fno-diagnostics-show-caret; the option -fdiagnostics-plain-output was added to request that diagnostic output look as plain as possible and stay more stable over time |
68f3b68
to
2703803
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last commit pushed LGTM
Controlled by three new options: * -fno-diagnostics-show-caret to disable code excerpts * -fno-diagnostics-show-line-numbers to not display line numbers * -fdiagnostics-plain-output to make output as plain as possible
2703803
to
490f31e
Compare
I think I added all your suggestions, I will commit it to svn as soon as CI is passed. Thanks ! |
Merged in SVN |
Sadly that broke C89 support in cobc/error.c: https://ci.appveyor.com/api/buildjobs/vqa49l488as7peee/log Please adjust to declare the variables at the beginning of the scope. Apart from that: what do you think of adding a std=c89 to the CI here? That should have likely called that. |
Sorry, I didn't see your comment, I am going to fix this problem asap |
Please drop a note if you think you'll have moved around the declarations in the next two hours as I'm doing it otherwise afterwards. |
to prevent this to be catched late, as happened with #85
to prevent this to be caught late, as happened with #85
to prevent this to be caught late, as happened with #85
Fixing C89 and additional changes to the format and some of the details done "upstream" in svn r5081. CI PR already referenced. |
to prevent this to be caught late, as happened with #85
Can you have a look for some late-cleanup on this, moving --> Note: I'm working on this now. |
to prevent this to be caught late, as happened with OCamlPro#85
In the meantime I've did that adjustment upstream. |
to prevent this to be caught late, as happened with OCamlPro#85
to prevent this to be caught late, as happened with OCamlPro#85
When a warning or error is printed, prints the source context with the line of the error, plus 2 lines before and after.
COBC_PREVIEW_ERROR can be used to set the option globally.