diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-28 18:55:38 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-28 18:55:38 +0000 |
commit | 96b973c7fa6169c83bc6530f1589a9ccf8a20d70 (patch) | |
tree | 17eb39bfae398799fc8f39adbe4dd62f9f8edaa4 /gcc/cp/class.c | |
parent | f576a2e4a07174b4080ea634f52bf48c6cfee7c3 (diff) | |
download | gcc-96b973c7fa6169c83bc6530f1589a9ccf8a20d70.tar.gz |
DR 1518
* class.c (type_has_user_provided_or_explicit_constructor): New.
(check_bases_and_members): Use it.
* cp-tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229501 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 685b7b3fc18..4465963523f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5150,6 +5150,33 @@ type_has_user_provided_constructor (tree t) return false; } +/* Returns true iff class T has a user-provided or explicit constructor. */ + +bool +type_has_user_provided_or_explicit_constructor (tree t) +{ + tree fns; + + if (!CLASS_TYPE_P (t)) + return false; + + if (!TYPE_HAS_USER_CONSTRUCTOR (t)) + return false; + + /* This can happen in error cases; avoid crashing. */ + if (!CLASSTYPE_METHOD_VEC (t)) + return false; + + for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + { + tree fn = OVL_CURRENT (fns); + if (user_provided_p (fn) || DECL_NONCONVERTING_P (fn)) + return true; + } + + return false; +} + /* Returns true iff class T has a non-user-provided (i.e. implicitly declared or explicitly defaulted in the class body) default constructor. */ @@ -5735,7 +5762,8 @@ check_bases_and_members (tree t) Again, other conditions for being an aggregate are checked elsewhere. */ CLASSTYPE_NON_AGGREGATE (t) - |= (type_has_user_provided_constructor (t) || TYPE_POLYMORPHIC_P (t)); + |= (type_has_user_provided_or_explicit_constructor (t) + || TYPE_POLYMORPHIC_P (t)); /* This is the C++98/03 definition of POD; it changed in C++0x, but we retain the old definition internally for ABI reasons. */ CLASSTYPE_NON_LAYOUT_POD_P (t) |