re PR c++/36944 (Revision 138123 breaks constructors with default arguments)
authorH.J. Lu <hongjiu.lu@intel.com>
Sun, 27 Jul 2008 17:40:04 +0000 (17:40 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Sun, 27 Jul 2008 17:40:04 +0000 (10:40 -0700)
gcc/cp/

2008-07-27  H.J. Lu  <hongjiu.lu@intel.com>

PR c++/36944
* class.c (type_has_user_provided_default_constructor): Handle
default parameters.

gcc/testsuite/

2008-07-27  H.J. Lu  <hongjiu.lu@intel.com>

PR c++/36944
* g++.dg/other/pr36944.C: New.

From-SVN: r138194

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr36944.C [new file with mode: 0644]

index c40808e6fd2bcfae80501af68dac608596414207..6a13613d860eaca8d7a7919b817c019c8782c886 100644 (file)
@@ -1,3 +1,9 @@
+2008-07-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c++/36944
+       * class.c (type_has_user_provided_default_constructor): Handle
+       default parameters.
+
 2008-07-27  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * decl.c (push_library_fn): Add a parameter for the exceptions that
index 18204608da36b0dd3fafd559702119ec811f1bb5..f7e46a717aaf49e62c821ef6621a576442ec1dee 100644 (file)
@@ -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;
index 95b0cde4944c2a411ca8ad8a730eb23e26ffba91..c32bc3d7d8bf7749af0830fe0b394f318b51cd56 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c++/36944
+       * g++.dg/other/pr36944.C: New.
+
 2008-07-27  Daniel Franke  <franke.daniel@gmail.com>
 
        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 (file)
index 0000000..b4a1dfa
--- /dev/null
@@ -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;
+};