This is the mail archive of the 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: Help! Regarding Bug 17896

On 01/25/2016 10:15 PM, Prasad Ghangal wrote:
> Hi!
> I would like to solve "Bug 17896 - The expression (a>0 & b>0) should
> give clearer warning message (-Wparentheses)"
> ( but I am new to
> gcc internals.
> Can someone please guide me how to do it?


A good starting point is probably this wiki page:
Note that there are some legal prerequisites (FSF has a policy of copyright
consolidation, and thus requires all contributors to assign copyright on their
work to FSF. I hope that you are OK with it). Right now GCC is in stage 4 of
it's development cycle, that means only regression fixes are accepted. The trunk
will be open again for new features and enhancements after release of GCC 6
(presumably in March, if nothing unusual happens), but you can still send your
patch for review and discuss it with maintainers as soon as it is ready.

As for the bug itself. Most of diagnostic reporting code is located in
'gcc/diagnostic.c' and 'gcc/diagnostic-show-locus.c'. You might want to set a
breakpoint on, say, 'report_diagnostic' function and look at the backtrace to
find out what code invokes it and how. Note that diagnostics API has been
improved since 2004 (when this bug was reported). For example, Clang gives
warnings like:

test.c:17:17: warning: | has lower precedence than ==; == will be evaluated
first [-Wparentheses]
  foo ((a == b) | b == c);
test.c:17:17: note: place parentheses around the '==' expression to silence this
  foo ((a == b) | b == c);
                  (     )
test.c:17:17: note: place parentheses around the | expression to evaluate it first
  foo ((a == b) | b == c);
       (           )

GCC says:

test.c:17:21: warning: suggest parentheses around comparison in operand of '|'
   foo ((a == b) | b == c);

As I understand, the bug report suggests that we say "suggest || instead of |
when joining booleans" instead. We now have the API to show fix-it hints, so it
would be nice to output something like

test.c:17:21: warning: suggest || instead of | when joining booleans
   foo ((a == b) | b == c);

Grep 'set_fixit_hint' in the source code to see an example of it's usage.

Good luck!

P.S. I also CC'd this message to one of major contributors to GCC diagnostics
module, maybe he could add something.

    Mikhail Maltsev

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