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

login
register
mail settings
Submitter Paolo Carlini
Date Nov. 7, 2013, 7 p.m.
Message ID <527BE347.5090307@oracle.com>
Download mbox | patch
Permalink /patch/289458/
State New
Headers show

Comments

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

in mainline, this commit:

     http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=199232

appear to have caused a diagnostic regression for the following (from 
c++/43906):

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?!?

Thanks!
Paolo.

///////////////////
Paolo Carlini - Nov. 7, 2013, 8:04 p.m.
.. 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.
Paolo Carlini - Nov. 9, 2013, 10:51 a.m.
... 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!)

Paolo

Patch

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.  */