aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-06-29 10:09:03 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-06-29 10:09:03 -0400
commit7b37a0c548b633d91e07fbb2c941828aafd5cd3b (patch)
treee966a3c2683437fd89e8b86e732a7bade6ed2775 /gcc/cp/init.c
parent2061820e0d4998d1792021cfa7283c2ce345b093 (diff)
downloadgcc-7b37a0c548b633d91e07fbb2c941828aafd5cd3b.zip
gcc-7b37a0c548b633d91e07fbb2c941828aafd5cd3b.tar.gz
gcc-7b37a0c548b633d91e07fbb2c941828aafd5cd3b.tar.bz2
init.c (build_value_init): Decide whether or not to zero-initialize based on user-providedness of default...
* init.c (build_value_init): Decide whether or not to zero-initialize based on user-providedness of default ctor, not any ctor. (build_value_init_noctor): Adjust assert. From-SVN: r175640
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 1719339..ac2b733 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -334,14 +334,20 @@ build_value_init (tree type, tsubst_flags_t complain)
if (CLASS_TYPE_P (type))
{
- if (type_has_user_provided_constructor (type))
+ /* Instead of the above, only consider the user-providedness of the
+ default constructor itself so value-initializing a class with an
+ explicitly defaulted default constructor and another user-provided
+ constructor works properly (c++std-core-19883). */
+ if (type_has_user_provided_default_constructor (type)
+ || (!TYPE_HAS_DEFAULT_CONSTRUCTOR (type)
+ && type_has_user_provided_constructor (type)))
return build_aggr_init_expr
(type,
build_special_member_call (NULL_TREE, complete_ctor_identifier,
NULL, type, LOOKUP_NORMAL,
complain),
complain);
- else if (type_build_ctor_call (type))
+ else if (TYPE_HAS_COMPLEX_DFLT (type))
{
/* This is a class that needs constructing, but doesn't have
a user-provided constructor. So we need to zero-initialize
@@ -371,7 +377,7 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
SFINAE-enabled. */
if (CLASS_TYPE_P (type))
{
- gcc_assert (!type_build_ctor_call (type));
+ gcc_assert (!TYPE_HAS_COMPLEX_DFLT (type));
if (TREE_CODE (type) != UNION_TYPE)
{