This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: implement fdiagnostics-print-source-range-info



On Aug 4, 2009, at 5:46 AM, Manuel López-Ibáñez wrote:


The following patch implements printing range info in diagnostics. It
is a very rough initial version but comments are appreciated. With
this patch for this code:

void bar(void)
{
 _Complex float Gamma;
 int *P;
 P = (P-42) + Gamma*4;
}

we print:

test.c: In function ‘bar’:
test.c:11:14:11.9-14:11.14-21: error: invalid operands to binary +
(have ‘int *’ and ‘complex float’)

which is not as good as Clang prints because we do not track the
boundaries of expressions. On the other hand, the above follows GNU
coding conventions [*] while Clang doesn't.

[*] http://www.gnu.org/prep/standards/standards.html#Errors

I understand why you want to follow the GNU conventions, but my understanding is that there *is* no convention for multiple ranges on one line, which is why we didn't follow it. The clang output looks like:


$ clang t.c -fdiagnostics-print-source-range-info
t.c:5:13:{5:6-5:12}{5:15-5:22}: error: invalid operands to binary expression ('int *' and '_Complex float')
P = (P-42) + Gamma*4;
~~~~~~ ^ ~~~~~~~
1 diagnostic generated.


In any case, if you really want to generate a different syntax, please use a different name for the option (like -fdiagnostics-print-source- range-info-gnu) so that Clang and GCC can conceivably be compatible with each other by offering both options. There is already at least one IDE that uses the clang format (and which already supports GCC), so it would be nice to not break it.

-Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]