[cfe-dev] Missing -Wparentheses warning

Xing GUO via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 5 02:07:34 PDT 2018


yes, you could follow the link https://reviews.llvm.org/D47687
I made this patch. You could see some comments about that

Cheers
Xing

On Sep 5, 2018 4:49 PM, "Mattias Haile via cfe-dev" <cfe-dev at lists.llvm.org>
wrote:

Hi,
Im looking at an old minor bug for "Missing -Wparentheses warning" where
clang do not warning for a missing parentheses in the case of "assert(x &&
val == 4 || (!x && val == 5));" whereas GCC would complain about missing
parentheses for x && val == 4.

https://bugs.llvm.org/show_bug.cgi?id=18971

The following comments are found in the code so it seems like a conscious
decision.
// Warn about arg1 || arg2 && arg3, as GCC 4.3+ does.
// We don't warn for 'assert(a || b && "bad")' since this is safe.

And since we never warn on macros

if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */)

This will not warn either.

define bar(x) \
  ( \
    (void) 0 \
  )

bar(x && val == 4 || !x && val == 5);

Not sure what to make of this bug.

Br. Mattias

PS. I'm new at this so play nice :)

_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180905/48e43052/attachment.html>


More information about the cfe-dev mailing list