diff mbox

[C++,Patch/RFC] PR 50961

Message ID 53C5943A.2050300@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 15, 2014, 8:51 p.m. UTC
Hi,

I have another half-baked issue about which I'd like to have some 
guidance... In this case too at least the draft patch works and passes 
the testsuite.

Essentially, something seems missing in the way we handle operator! 
applied to a TEMPLATE_ID_EXPR, whereas the non-template version already 
works: using perform_implicit_conversion alone leads to "cannot resolve 
overloaded function ‘foo’ based on conversion to type ‘bool’". I'm not 
sure however that a decay_conversion is in general correct...

Thanks!
Paolo.

//////////////////

Comments

Jason Merrill July 15, 2014, 9:46 p.m. UTC | #1
You need to call resolve_nondeduced_context at some point.  This doesn't 
seem to be the right place, since you also want to handle code like "if 
(foo<void>)".  Maybe in resolve_address_of_overloaded_function just 
before the error?

Jason
diff mbox

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 212559)
+++ cp/typeck.c	(working copy)
@@ -5675,7 +5675,8 @@  cp_build_unary_op (enum tree_code code, tree xarg,
       break;
 
     case TRUTH_NOT_EXPR:
-      arg = perform_implicit_conversion (boolean_type_node, arg,
+      arg = perform_implicit_conversion (boolean_type_node,
+					 decay_conversion (arg, complain),
 					 complain);
       val = invert_truthvalue_loc (input_location, arg);
       if (arg != error_mark_node)
Index: testsuite/g++.dg/template/operator13.C
===================================================================
--- testsuite/g++.dg/template/operator13.C	(revision 0)
+++ testsuite/g++.dg/template/operator13.C	(working copy)
@@ -0,0 +1,4 @@ 
+// PR c++/50961
+
+template < class > void foo ();
+bool b = !foo<void>;