From ff60c6685c150b8371d35fb471aebf628e2c1b94 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 27 Jul 2008 17:40:04 +0000 Subject: [PATCH] re PR c++/36944 (Revision 138123 breaks constructors with default arguments) gcc/cp/ 2008-07-27 H.J. Lu PR c++/36944 * class.c (type_has_user_provided_default_constructor): Handle default parameters. gcc/testsuite/ 2008-07-27 H.J. Lu PR c++/36944 * g++.dg/other/pr36944.C: New. From-SVN: r138194 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 14 +++++++++----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/pr36944.C | 26 ++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/pr36944.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c40808e6fd2..6a13613d860 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-07-27 H.J. Lu + + PR c++/36944 + * class.c (type_has_user_provided_default_constructor): Handle + default parameters. + 2008-07-27 Paolo Carlini * decl.c (push_library_fn): Add a parameter for the exceptions that diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 18204608da3..f7e46a717aa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4107,7 +4107,7 @@ type_has_user_provided_constructor (tree t) bool type_has_user_provided_default_constructor (tree t) { - tree fns; + tree fns, args; if (!TYPE_HAS_USER_CONSTRUCTOR (t)) return false; @@ -4116,10 +4116,14 @@ type_has_user_provided_default_constructor (tree t) { tree fn = OVL_CURRENT (fns); if (TREE_CODE (fn) == FUNCTION_DECL - && user_provided_p (fn) - && (skip_artificial_parms_for (fn, DECL_ARGUMENTS (fn)) - == NULL_TREE)) - return true; + && user_provided_p (fn)) + { + args = FUNCTION_FIRST_USER_PARMTYPE (fn); + while (args && TREE_PURPOSE (args)) + args = TREE_CHAIN (args); + if (!args || args == void_list_node) + return true; + } } return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95b0cde4944..c32bc3d7d8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-07-27 H.J. Lu + + PR c++/36944 + * g++.dg/other/pr36944.C: New. + 2008-07-27 Daniel Franke PR fortran/36724 diff --git a/gcc/testsuite/g++.dg/other/pr36944.C b/gcc/testsuite/g++.dg/other/pr36944.C new file mode 100644 index 00000000000..b4a1dfa46fd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr36944.C @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +class XObject +{ +public: + int foo; +}; + +class XObjectPtr +{ +public: + explicit + XObjectPtr(XObject* theXObject = 0) : m_xobjectPtr(theXObject) + { + } + +private: + XObject * m_xobjectPtr; +}; + +class SelectionEvent +{ +public: + SelectionEvent(bool selection) : m_selection() {} + const XObjectPtr m_selection; +}; -- 2.30.2