On Thu, 11 Oct 2018 at 13:20, David Gilbert wrote: > > Hello, > > I have been scouring the net and the gcc documentation without success to > try and find a definitive description of the gcc diagnostic messages. > > I am working on a project in which I need to parse the gcc compiler > diagnostics in order to automate the correction of the source code being > compiled. I assume you're aware of the -fdiagnostics-parseable-fixits and -fdiagnostics-generate-patch options? They don't affect all diagnostics, only those where it makes sense and the compiler can reliably suggest a fix. > For most of the diagnostics, the semantics are fairly self-evident but I am > left with a few questions: > > . In some cases, the 'mark' line that follows an 'invalid > conversion' diagnostic description identifies the object that generated the > diagnostic with a '^' and a string of '~'s but in some cases the mark line > only contains a caret that identifies the closing parenthesis of a function > call or declaration and the column value in the diagnostic also points to > this location. Why are there two behaviors? Because in some cases the location info provided to the diagnostic is just wherever the parser stopped. In some cases there's more information. > . In the case described in the first question above, I have found > that the error:/warning: diagnostic is followed by a note: diagnostic that > DOES identify the argument that provoked the diagnostic. Is this entirely > consistent - i.e. will this 'note:' always be present? I doubt it. Those diagnostics are not really designed to be machine readable. > . What I am really trying to find is a comprehensive description of > the gcc diagnostic message syntax. This is not in the documentation and > does not appear to be on the web either. Can you point me at a source? I don't think there is one. There is no formal "schema" for diagnostics. Any informal rules they're meant to follow almost certainly aren't followed universally by all diagnostics.