diff options
author | Jason Merrill <jason@redhat.com> | 2013-10-31 11:45:04 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-10-31 11:45:04 -0400 |
commit | c1c2162eadef6e5101855bfd130e9aae154210a7 (patch) | |
tree | 149c1199defc0e613fbac5a900e06d8a2a26c6ec | |
parent | b8aaa1a3b97790dfaf45c2fdf671ed1ae81e3b07 (diff) | |
download | gcc-c1c2162eadef6e5101855bfd130e9aae154210a7.zip gcc-c1c2162eadef6e5101855bfd130e9aae154210a7.tar.gz gcc-c1c2162eadef6e5101855bfd130e9aae154210a7.tar.bz2 |
semantics.c (cxx_eval_call_expression): Handle trivial value-initialization.
* semantics.c (cxx_eval_call_expression): Handle trivial
value-initialization.
* typeck2.c (store_init_value): Call maybe_constant_init after
cxx_constant_value.
From-SVN: r204266
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 16 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e061110..c7a0e5d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2013-10-31 Jason Merrill <jason@redhat.com> + * semantics.c (cxx_eval_call_expression): Handle trivial + value-initialization. + * typeck2.c (store_init_value): Call maybe_constant_init after + cxx_constant_value. + * decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL. * decl2.c (build_cleanup): Just call cxx_maybe_build_cleanup. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bbdf81a..de3e8e7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8289,12 +8289,18 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, return t; } - /* Shortcut trivial copy constructor/op=. */ - if (call_expr_nargs (t) == 2 && trivial_fn_p (fun)) + /* Shortcut trivial constructor/op=. */ + if (trivial_fn_p (fun)) { - tree arg = convert_from_reference (get_nth_callarg (t, 1)); - return cxx_eval_constant_expression (old_call, arg, allow_non_constant, - addr, non_constant_p, overflow_p); + if (call_expr_nargs (t) == 2) + { + tree arg = convert_from_reference (get_nth_callarg (t, 1)); + return cxx_eval_constant_expression (old_call, arg, allow_non_constant, + addr, non_constant_p, overflow_p); + } + else if (TREE_CODE (t) == AGGR_INIT_EXPR + && AGGR_INIT_ZERO_FIRST (t)) + return build_zero_init (DECL_CONTEXT (fun), NULL_TREE, false); } /* If in direct recursive call, optimize definition search. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index d6ff3ca..9da8e3d 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -775,7 +775,6 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) { bool const_init; value = fold_non_dependent_expr (value); - value = maybe_constant_init (value); if (DECL_DECLARED_CONSTEXPR_P (decl) || DECL_IN_AGGR_P (decl)) { @@ -786,6 +785,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) else value = cxx_constant_value (value); } + value = maybe_constant_init (value); const_init = (reduced_constant_expression_p (value) || error_operand_p (value)); DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init; |