[C++,/,RFC] Fixing a diagnostic regression caused by the fix for c++/56930

Message ID 527BE347.5090307@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 7, 2013, 7 p.m.
Hi all, Jason,

in mainline, this commit:


appear to have caused a diagnostic regression for the following (from 

extern void z();
void f() { if ( z ) z(); }

that is, with -Waddress we warn twice, because in cp_convert_and_check 
we call cp_convert twice with the same arguments. How shall we deal with 
this? Something like the attached, or you have in mind something more 
neat, I don't know?!?




Paolo Carlini Nov. 7, 2013, 8:04 p.m. | #1
.. nope, p2 isn't Ok, because we would return a different tree 
depending on complain and . c_inhibit_evaluation_warnings. Thus either 
something closer to p or something else.

Paolo Carlini Nov. 9, 2013, 10:51 a.m. | #2
... I think that a much better fix would be calling the second cp_convert with tf_none and make sure the information is propagated down to the c-common code emitting the diagnostic. I'm going to work on it. Note anyway that we still have the option of not calling cp_convert when it's not necessary, as an optimization (isn't a trivial function!)



Index: cvt.c
--- cvt.c	(revision 204536)
+++ cvt.c	(working copy)
@@ -629,7 +629,8 @@  cp_convert_and_check (tree type, tree expr, tsubst
       tree folded = maybe_constant_value (expr);
       tree stripped = folded;
-      tree folded_result = cp_convert (type, folded, complain);
+      tree folded_result
+	= folded != expr ? cp_convert (type, folded, complain) : result;
       /* maybe_constant_value wraps an INTEGER_CST with TREE_OVERFLOW in a
 	 NOP_EXPR so that it isn't TREE_CONSTANT anymore.  */