aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-12-08 08:36:09 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-12-08 08:36:09 +0000
commitdb24eb1f4fcc6fa8330376179278261e02b717b5 (patch)
tree9d5171ca690b8c2e8078b4b944da983e3de547f6 /gcc/cp/pt.c
parent89b17498044f87f7bc14f56782434c062730db8d (diff)
downloadgcc-db24eb1f4fcc6fa8330376179278261e02b717b5.zip
gcc-db24eb1f4fcc6fa8330376179278261e02b717b5.tar.gz
gcc-db24eb1f4fcc6fa8330376179278261e02b717b5.tar.bz2
re PR c++/18803 (rejects access to operator() in template)
cp: PR c++/18803 * cp-tree.h (REFERENCE_REF_P): New. (CPTI_TYPE_INFO_TYPE): Rename to ... (CPTI_CONST_TYPE_INFO_TYPE): ... here. (CPTI_TYPE_INFO_REF_TYPE): Remove. (type_info_type_node): Rename to ... (const_type_info_type_node): ... here. (type_info_ref_type): Remove. * call.c (build_user_type_conversion): Reformat. (resolve_args): Do not convert_from_reference. (build_object_call): Call convert_from_reference. (prep_operand): Do not convert_from_reference. (build_new_method_call): Likewise. * class.c (build_vfield_ref): Likewise. * cvt.c (convert_to_reference): Likewise. (convert_from_reference): Build INDIRECT_REF here, not with build_indirect_ref. (convert_force): Do not convert_from_reference. (build_expr_type_conversion): Likewise. * decl.c (grok_reference_init): Likewise. * decl2.c (delete_sanity): Likewise. * except.c (initialize_handler_parm): Use POINTER_TYPE_P. * init.c (build_dtor_call): Do not convert_from_reference. * parser.c (cp_parser_template_argument): Unwrap indirected reference. Allow TEMPLATE_PARM_INDEX as an object parm. * pt.c (tsubst_copy_and_build) <case INDIRECT_REF>: Use convert_from_reference, if indicated. <case CALL_EXPR>: Do not convert_from_reference. <case PARM_DECL, VAR_DECL>: Convert_from_reference if needed. (tsubst_initializer_list): Do not convert_from_reference. * rtti.c (init_rtti_processing): Adjust node creation. (throw_bad_typeid): Use const_type_info_type_node. Do not convert_from_reference. (typeid_ok_p): Use const_type_info_type_node. (build_typeid, get_typeid): Always return type_info typed node. (build_dynamic_cast_1): Dont convert_from_reference. Refactor. * semantics.c (finish_stmt_expr_expr): Do not convert_from_reference. (finish_id_expression): Convert_from_reference as appropriate. * typeck.c (decay_conversion): Do not convert_from_reference. (finish_class_member_access_expr): Likewise. (build_indirect_ref): Use POINTER_TYPE_P. (convert_arguments): Do not convert_from_reference. (build_modify_expr): Likewise. (convert_for_initialization): Likewise. * typeck2.c (build_x_arrow): Likewise. testsuite: PR c++/18803 * g++.dg/template/operator5.C: New. From-SVN: r91863
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9bf396b..6e34ba6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8390,7 +8390,18 @@ tsubst_copy_and_build (tree t,
}
case INDIRECT_REF:
- return build_x_indirect_ref (RECUR (TREE_OPERAND (t, 0)), "unary *");
+ {
+ tree r = RECUR (TREE_OPERAND (t, 0));
+
+ if (REFERENCE_REF_P (t))
+ {
+ gcc_assert (TREE_CODE (TREE_TYPE (r)) == REFERENCE_TYPE);
+ r = convert_from_reference (r);
+ }
+ else
+ r = build_x_indirect_ref (r, "unary *");
+ return r;
+ }
case NOP_EXPR:
return build_nop
@@ -8626,8 +8637,6 @@ tsubst_copy_and_build (tree t,
if (DECL_P (function))
mark_used (function);
- function = convert_from_reference (function);
-
if (TREE_CODE (function) == OFFSET_REF)
return build_offset_ref_call_from_tree (function, call_args);
if (TREE_CODE (function) == COMPONENT_REF)
@@ -8815,13 +8824,21 @@ tsubst_copy_and_build (tree t,
return build_typeid (operand_0);
}
- case PARM_DECL:
- return convert_from_reference (tsubst_copy (t, args, complain, in_decl));
-
case VAR_DECL:
- if (args)
- t = tsubst_copy (t, args, complain, in_decl);
- return convert_from_reference (t);
+ if (!args)
+ return t;
+ /* Fall through */
+
+ case PARM_DECL:
+ {
+ tree r = tsubst_copy (t, args, complain, in_decl);
+
+ if (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE)
+ /* If the original type was a reference, we'll be wrapped in
+ the appropriate INDIRECT_REF. */
+ r = convert_from_reference (r);
+ return r;
+ }
case VA_ARG_EXPR:
return build_x_va_arg (RECUR (TREE_OPERAND (t, 0)),
@@ -11560,7 +11577,6 @@ tsubst_initializer_list (tree t, tree argvec)
{
tree decl;
tree init;
- tree val;
decl = tsubst_copy (TREE_PURPOSE (t), argvec, tf_error | tf_warning,
NULL_TREE);
@@ -11570,14 +11586,6 @@ tsubst_initializer_list (tree t, tree argvec)
init = tsubst_expr (TREE_VALUE (t), argvec, tf_error | tf_warning,
NULL_TREE);
- if (!init)
- ;
- else if (TREE_CODE (init) == TREE_LIST)
- for (val = init; val; val = TREE_CHAIN (val))
- TREE_VALUE (val) = convert_from_reference (TREE_VALUE (val));
- else if (init != void_type_node)
- init = convert_from_reference (init);
-
in_base_initializer = 0;
if (decl)