aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-12-22 03:34:55 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-12-22 03:34:55 +0000
commit943e3eded2ab29d35a266cb0d7bfcbda9d96e038 (patch)
tree3c4219827d7473d470169c52b58780a7e3078422 /gcc/cp/call.c
parentbe99edf8839b914004bc3f96f5acdc515198db86 (diff)
downloadgcc-943e3eded2ab29d35a266cb0d7bfcbda9d96e038.zip
gcc-943e3eded2ab29d35a266cb0d7bfcbda9d96e038.tar.gz
gcc-943e3eded2ab29d35a266cb0d7bfcbda9d96e038.tar.bz2
re PR c++/18378 (ICE when returning a copy of a packed member)
PR c++/18378 * call.c (convert_like_real): Do not permit the use of a copy constructor to copy a packed field. PR c++/17413 * decl.c (grokdeclarator): Return error_mark_node, not void_type_node, to indicate errors. * parser.c (cp_parser_template_parameter_list): Robustify. (cp_parser_template_parameter): Likewise. PR c++/19034 * tree.c (cp_tree_equal): Handle OVERLOAD. PR c++/18378 * g++.dg/ext/packed8.C: New test. PR c++/13268 * g++.dg/template/crash31.C: New test. PR c++/19034 * g++.dg/template/crash30.C: New test. From-SVN: r92486
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index af6f7d8..69e06e0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4288,13 +4288,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
if (convs->need_temporary_p || !lvalue_p (expr))
{
tree type = convs->u.next->type;
+ cp_lvalue_kind lvalue = real_lvalue_p (expr);
if (!CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (ref_type)))
{
/* If the reference is volatile or non-const, we
cannot create a temporary. */
- cp_lvalue_kind lvalue = real_lvalue_p (expr);
-
if (lvalue & clk_bitfield)
error ("cannot bind bitfield %qE to %qT",
expr, ref_type);
@@ -4305,6 +4304,20 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
error ("cannot bind rvalue %qE to %qT", expr, ref_type);
return error_mark_node;
}
+ /* If the source is a packed field, and we must use a copy
+ constructor, then building the target expr will require
+ binding the field to the reference parameter to the
+ copy constructor, and we'll end up with an infinite
+ loop. If we can use a bitwise copy, then we'll be
+ OK. */
+ if ((lvalue & clk_packed)
+ && CLASS_TYPE_P (type)
+ && !TYPE_HAS_TRIVIAL_INIT_REF (type))
+ {
+ error ("cannot bind packed field %qE to %qT",
+ expr, ref_type);
+ return error_mark_node;
+ }
expr = build_target_expr_with_type (expr, type);
}