diff mbox

[C++] PR 58255

Message ID 521DFA0A.4010105@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Aug. 28, 2013, 1:24 p.m. UTC
Hi,

for value-initialization (thus void_type_node as init), explicit should 
not matter, thus we shouldn't set LOOKUP_ONLYCONVERTING. I also double 
checked that we do the right thing for testcases like:

struct A {
   explicit A(int = 0);
};

A a1 = 1; /* error */
A a2;     /* Ok */
A a3(2);  /* Ok */

As expected, in such cases init is an INTEGER_CST, a NULL_TREE and a 
TREE_LIST of a single INTEGER_CST, respectively.

Booted and tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
/cp
2013-08-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58255
	* init.c (build_aggr_init): When init == void_type_node do not
	set LOOKUP_ONLYCONVERTING.

/testsuite
2013-08-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58255
	* g++.dg/cpp0x/dc7.C: New.

Comments

Jason Merrill Aug. 28, 2013, 9:30 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/init.c
===================================================================
--- cp/init.c	(revision 202020)
+++ cp/init.c	(working copy)
@@ -1464,7 +1464,8 @@  build_aggr_init (tree exp, tree init, int flags, t
   TREE_READONLY (exp) = 0;
   TREE_THIS_VOLATILE (exp) = 0;
 
-  if (init && TREE_CODE (init) != TREE_LIST
+  if (init && init != void_type_node
+      && TREE_CODE (init) != TREE_LIST
       && !(TREE_CODE (init) == TARGET_EXPR
 	   && TARGET_EXPR_DIRECT_INIT_P (init))
       && !(BRACE_ENCLOSED_INITIALIZER_P (init)
Index: testsuite/g++.dg/cpp0x/dc7.C
===================================================================
--- testsuite/g++.dg/cpp0x/dc7.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/dc7.C	(working copy)
@@ -0,0 +1,7 @@ 
+// PR c++/58255
+// { dg-do compile { target c++11 } }
+
+struct A {
+  explicit A() { }
+  A(int x) : A() { }
+};