On 09/05/16 23:50, Bernd Edlinger wrote: > Hi, > > I've noticed that there is already a -Wparentheses warning for code like > > int y = x == 2 ?: 1 > > => warning: the omitted middle operand in ?: will always be 'true', > suggest explicit middle operand [-Wparentheses] > > But it is not emitted for code that uses bool, like: > > void foo(bool x) > { > int y = x ?: 1; > > and under C it is not emitted for compound expressions > that end with a comparison, like: > > int y = (i++,i==1) ?: 1; > > C++ is OK, but does only miss to warn on the bool data type. > > The attached patch should fix these warnings. > Well, reg-testing showed few test cases were broken, that made me aware of an issue with templates when the LHS of ?: is dependent. In that case the type is not available at the template declaration, and the warning cannot be generated at the declaration but only when the template is instantiated. The new patch fixes this, and a pre-existing issue, entered as PR 77496, when the type can not be implicitly converted to boolean. Boot-strapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Thanks Bernd.