-
Type:
Enhancement
-
Resolution: Unresolved
-
Priority:
Low
-
Code Generation Tools
-
CODEGEN-13450
-
ARMCLANG_4.0.1.LTS
-
default
Build the attached source file ...
% tiarmclang -c file.c
file.c:4:14: warning: & has lower precedence than !=; != will be evaluated first [-Wparentheses]
4 | if (arg1 & 0x1u != 0)
| ^~~~~~~~~~~
file.c:4:14: note: place parentheses around the '!=' expression to silence this warning
4 | if (arg1 & 0x1u != 0)
| ^
| ( )
file.c:4:14: note: place parentheses around the & expression to evaluate it first
4 | if (arg1 & 0x1u != 0)
| ^
| ( )
file.c:13:15: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ~~~~~^~~~~~~
file.c:13:15: note: remove extraneous parentheses around the comparison to silence this warning
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ~ ^ ~
file.c:13:15: note: use '=' to turn this equality comparison into an assignment
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ^~
| =
The user wants to change the handling of the first diagnostic to an error, while continuing to handle the second diagnostic as a warning. There appears to be no method for doing that. For example:
% tiarmclang -c -Werror=parentheses -Wparentheses-equality file.c
file.c:4:14: error: & has lower precedence than !=; != will be evaluated first
[-Werror,-Wparentheses]
4 | if (arg1 & 0x1u != 0)
| ^~~~~~~~~~~
file.c:4:14: note: place parentheses around the '!=' expression to silence this warning
4 | if (arg1 & 0x1u != 0)
| ^
| ( )
file.c:4:14: note: place parentheses around the & expression to evaluate it first
4 | if (arg1 & 0x1u != 0)
| ^
| ( )
file.c:13:15: error: equality comparison with extraneous parentheses
[-Werror,-Wparentheses-equality]
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ~~~~~^~~~~~~
file.c:13:15: note: remove extraneous parentheses around the comparison to silence this warning
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ~ ^ ~
file.c:13:15: note: use '=' to turn this equality comparison into an assignment
13 | if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
| ^~
| =
Now both diagnostics are handled as an error.
The problem is the diagnostic category -Wparentheses serves multiple purposes. It is both an umbrella category that includes other categories like -Wparentheses-equality, as well as a category on its own.