aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-01-02 12:53:28 -0500
committerJason Merrill <jason@gcc.gnu.org>2012-01-02 12:53:28 -0500
commitab807569b6233bc5226dda1e67504d7d09114529 (patch)
tree2c8e3f5c52a1207402ee89b81e619127e92c0ab3 /gcc/cp
parentd28c2dcd712c9c79f8608c136f977f5d925886ea (diff)
downloadgcc-ab807569b6233bc5226dda1e67504d7d09114529.zip
gcc-ab807569b6233bc5226dda1e67504d7d09114529.tar.gz
gcc-ab807569b6233bc5226dda1e67504d7d09114529.tar.bz2
DR 1359 PR c++/51675
DR 1359 PR c++/51675 * method.c (walk_field_subobs): Don't check for uninitialized fields in a union. (synthesized_method_walk): Check here. From-SVN: r182810
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/method.c16
2 files changed, 18 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7668a7b..9eb6882 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2012-01-02 Jason Merrill <jason@redhat.com>
+ DR 1359
+ PR c++/51675
+ * method.c (walk_field_subobs): Don't check for uninitialized
+ fields in a union.
+ (synthesized_method_walk): Check here.
+
DR 325
PR c++/51666
* parser.c (cp_parser_cache_defarg): Split out...
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 8101f8a..cf2a713 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1063,7 +1063,8 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
/* For an implicitly-defined default constructor to be constexpr,
every member must have a user-provided default constructor or
an explicit initializer. */
- if (constexpr_p && !CLASS_TYPE_P (mem_type))
+ if (constexpr_p && !CLASS_TYPE_P (mem_type)
+ && TREE_CODE (DECL_CONTEXT (field)) != UNION_TYPE)
{
*constexpr_p = false;
if (msg)
@@ -1208,12 +1209,19 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,
resolution, so a constructor can be trivial even if it would otherwise
call a non-trivial constructor. */
if (expected_trivial
- && !diag
&& (!copy_arg_p || cxx_dialect < cxx0x))
{
if (constexpr_p && sfk == sfk_constructor)
- *constexpr_p = trivial_default_constructor_is_constexpr (ctype);
- return;
+ {
+ bool cx = trivial_default_constructor_is_constexpr (ctype);
+ *constexpr_p = cx;
+ if (diag && !cx && TREE_CODE (ctype) == UNION_TYPE)
+ /* A trivial constructor doesn't have any NSDMI. */
+ inform (input_location, "defaulted default constructor does "
+ "not initialize any non-static data member");
+ }
+ if (!diag)
+ return;
}
++cp_unevaluated_operand;