summaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-27 18:56:13 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-27 18:56:13 +0000
commitb566a4fd1a917fc9a9d1f8116171c8798efb7b7e (patch)
treec95fa21322f4c7608254fa16bb33ea36db219406 /gcc/cp/class.c
parent0b577e62c3eaa67012a8d4fd430e47e00f8d3916 (diff)
downloadgcc-b566a4fd1a917fc9a9d1f8116171c8798efb7b7e.tar.gz
PR c++/42844
* decl.c (check_for_uninitialized_const_var): Handle classes that need constructing, too. (check_initializer): Call it for classes that need constructing, too. * class.c (in_class_defaulted_default_constructor): New. * cp-tree.h: Declare it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158797 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1bab07dd42c..26da21b8c82 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1,6 +1,6 @@
/* Functions related to building classes and their related objects.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -4177,6 +4177,34 @@ type_has_user_nondefault_constructor (tree t)
return false;
}
+/* Returns the defaulted constructor if T has one. Otherwise, returns
+ NULL_TREE. */
+
+tree
+in_class_defaulted_default_constructor (tree t)
+{
+ tree fns, args;
+
+ if (!TYPE_HAS_USER_CONSTRUCTOR (t))
+ return NULL_TREE;
+
+ for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+ {
+ tree fn = OVL_CURRENT (fns);
+
+ if (DECL_DEFAULTED_IN_CLASS_P (fn))
+ {
+ args = FUNCTION_FIRST_USER_PARMTYPE (fn);
+ while (args && TREE_PURPOSE (args))
+ args = TREE_CHAIN (args);
+ if (!args || args == void_list_node)
+ return fn;
+ }
+ }
+
+ return NULL_TREE;
+}
+
/* Returns true iff FN is a user-provided function, i.e. user-declared
and not defaulted at its first declaration; or explicit, private,
protected, or non-const. */