This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, Since June 2003, Peter Dimov has been playing with the decltype implementation and experimenting with various incarnations of the "bind" proposal. He presented me with some constructs that were rejected; I traced those invalid rejects as failures to implement SFINAE for function calls. This patch fixes that on the cxx-reflection branch. The issue remains on mainline -- to exercise it on mainline, one would need first to implement mangling of __typeof__ type-expressions, which is still the subject of many PRs. Peter autorized me to reproduce the following part of his mail (dated from late June 2003, also vaguely connected to the recent TR thread): # I've attached the two examples. bind.cpp is a prototype implementation of a # subset of N1438 that I ported to decltype, and decltype.cpp is the # simplified version that works. # # Speaking of which, are there any plans to implement the TR in libstdc++? :-) The programs bind.cpp and decltype.cpp are also attached below. With this patch, we're getting past the failure point he reported. However, the failure is an error in Peter's program. I'm counting his effort and cleverness to get around many C++ restrictions as evidence for need of namespace templates ;-) -- Gaby Index: ChangeLog.cxx-reflection =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/ChangeLog.cxx-reflection,v retrieving revision 1.1.2.2 diff -p -r1.1.2.2 ChangeLog.cxx-reflection *** ChangeLog.cxx-reflection 15 Jun 2003 17:31:45 -0000 1.1.2.2 --- ChangeLog.cxx-reflection 7 Oct 2003 10:07:38 -0000 *************** *** 1,3 **** --- 1,8 ---- + 2003-10-06 Gabriel Dos Reis <gdr@integrable-solutions.net> + + Implement SFINAE for calls. + * c-common.h (build_function_call): Move to c-tree.h. + 2003-06-14 Gabriel Dos Reis <gdr@integrable-solutions.net> * c-common.h (enum rid): Add new enumeration RID_DECLTYPE. Index: c-common.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-common.h,v retrieving revision 1.168.4.11 diff -p -r1.168.4.11 c-common.h *** c-common.h 5 Oct 2003 09:35:24 -0000 1.168.4.11 --- c-common.h 7 Oct 2003 10:07:39 -0000 *************** extern int case_compare (splay_tree_key, *** 1284,1291 **** extern tree c_add_case_label (splay_tree, tree, tree, tree); - extern tree build_function_call (tree, tree); - extern tree finish_label_address_expr (tree); /* Same function prototype, but the C and C++ front ends have --- 1284,1289 ---- Index: c-tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v retrieving revision 1.110.4.9 diff -p -r1.110.4.9 c-tree.h *** c-tree.h 5 Oct 2003 09:35:26 -0000 1.110.4.9 --- c-tree.h 7 Oct 2003 10:07:39 -0000 *************** extern void c_expand_decl_stmt (tree); *** 213,218 **** --- 213,219 ---- extern void c_static_assembler_name (tree); extern tree make_pointer_declarator (tree, tree); extern void merge_translation_unit_decls (void); + extern tree build_function_call (tree, tree); /* in c-objc-common.c */ extern int c_disregard_inline_limits (tree); Index: cp/ChangeLog.cxx-reflection =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/Attic/ChangeLog.cxx-reflection,v retrieving revision 1.1.2.5 diff -p -r1.1.2.5 ChangeLog.cxx-reflection *** cp/ChangeLog.cxx-reflection 5 Oct 2003 21:32:24 -0000 1.1.2.5 --- cp/ChangeLog.cxx-reflection 7 Oct 2003 10:07:41 -0000 *************** *** 1,3 **** --- 1,31 ---- + 2003-10-06 Gabriel Dos Reis <gdr@integrable-solutions.net> + + Implement SFINAE for calls. + * cp-tree.h (build_function_call): Declare. + (build_new_function_call): Change prototype. + (build_offset_ref_call_from_tree): Likewise. + * call.c (build_field_call): Adjust call. + (build_new_function_call): Likewise. Accept a complain parameter. + Tidy. + (build_object_call): Likewise. + (build_op_delete_call): Adjust call to build_function_call. + (build_new_op): Adjust call. + + * decl.c (register_dtor_fn): Likewise. + * decl2.c (generate_ctor_or_dtor_function): Likewise. + (build_offset_ref_call_from_tree): Accept a complain parameter. + Adjust calls. + * except.c (do_begin_catch): Adjust call to build_function_call. + (do_end_catch): Likewise. + (do_allocate_exception): Likewise. + (do_free_exception): Likewise. + (build_throw): Likewise. + * init.c (build_new_1): Likewise. + * semantics.c (finish_call_expr): Aceept complain parameter. + * pt.c (tsubst_copy_and_build): Likewise. + * parser.c (cp_parser_postfix_expression): Likewise. + * typeck.c (build_function_call): Accept complain parameter. + 2003-10-05 Gabriel Dos Reis <gdr@integrable-solutions.net> Mangle decltype in a reversible way. Index: cp/call.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v retrieving revision 1.358.4.11 diff -p -r1.358.4.11 call.c *** cp/call.c 5 Oct 2003 08:43:08 -0000 1.358.4.11 --- cp/call.c 7 Oct 2003 10:07:44 -0000 *************** static tree build_java_interface_fn_ref *** 56,62 **** static tree convert_like_real (tree, tree, tree, int, int, bool); static void op_error (enum tree_code, enum tree_code, tree, tree, tree, const char *); ! static tree build_object_call (tree, tree); static tree resolve_args (tree); static struct z_candidate *build_user_type_conversion_1 (tree, tree, int); static void print_z_candidate (const char *, struct z_candidate *); --- 56,62 ---- static tree convert_like_real (tree, tree, tree, int, int, bool); static void op_error (enum tree_code, enum tree_code, tree, tree, tree, const char *); ! static tree build_object_call (tree, tree, bool); static tree resolve_args (tree); static struct z_candidate *build_user_type_conversion_1 (tree, tree, int); static void print_z_candidate (const char *, struct z_candidate *); *************** build_field_call (tree instance_ptr, tre *** 157,163 **** || (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE && (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == FUNCTION_TYPE))) ! return build_function_call (instance, parms); } return NULL_TREE; --- 157,163 ---- || (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE && (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == FUNCTION_TYPE))) ! return build_function_call (instance, parms, true); } return NULL_TREE; *************** perform_overload_resolution (tree fn, *** 2720,2726 **** or a static member function) with the ARGS. */ tree ! build_new_function_call (tree fn, tree args) { struct z_candidate *candidates, *cand; bool any_viable_p; --- 2720,2726 ---- or a static member function) with the ARGS. */ tree ! build_new_function_call (tree fn, tree args, bool complain) { struct z_candidate *candidates, *cand; bool any_viable_p; *************** build_new_function_call (tree fn, tree a *** 2734,2750 **** if (!cand) { if (!any_viable_p && candidates && ! candidates->next) ! return build_function_call (candidates->fn, args); if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) fn = TREE_OPERAND (fn, 0); ! if (!any_viable_p) ! error ("no matching function for call to `%D(%A)'", ! DECL_NAME (OVL_CURRENT (fn)), args); ! else ! error ("call of overloaded `%D(%A)' is ambiguous", ! DECL_NAME (OVL_CURRENT (fn)), args); ! if (candidates) ! print_z_candidates (candidates); return error_mark_node; } --- 2734,2753 ---- if (!cand) { if (!any_viable_p && candidates && ! candidates->next) ! return build_function_call (candidates->fn, args, complain); if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) fn = TREE_OPERAND (fn, 0); ! if (complain) ! { ! if (!any_viable_p) ! error ("no matching function for call to `%D(%A)'", ! DECL_NAME (OVL_CURRENT (fn)), args); ! else ! error ("call of overloaded `%D(%A)' is ambiguous", ! DECL_NAME (OVL_CURRENT (fn)), args); ! if (candidates) ! print_z_candidates (candidates); ! } return error_mark_node; } *************** build_operator_new_call (tree fnname, tr *** 2840,2846 **** } static tree ! build_object_call (tree obj, tree args) { struct z_candidate *candidates = 0, *cand; tree fns, convs, mem_args = NULL_TREE; --- 2843,2849 ---- } static tree ! build_object_call (tree obj, tree args, bool complain) { struct z_candidate *candidates = 0, *cand; tree fns, convs, mem_args = NULL_TREE; *************** build_object_call (tree obj, tree args) *** 2851,2857 **** { /* It's no good looking for an overloaded operator() on a pointer-to-member-function. */ ! error ("pointer-to-member function %E cannot be called without an object; consider using .* or ->*", obj); return error_mark_node; } --- 2854,2862 ---- { /* It's no good looking for an overloaded operator() on a pointer-to-member-function. */ ! if (complain) ! error ("pointer-to-member function %E cannot be called without " ! "an object; consider using .* or ->*", obj); return error_mark_node; } *************** build_object_call (tree obj, tree args) *** 2925,2932 **** cand = tourney (candidates); if (cand == 0) { ! error ("call of `(%T) (%A)' is ambiguous", TREE_TYPE (obj), args); ! print_z_candidates (candidates); return error_mark_node; } --- 2930,2940 ---- cand = tourney (candidates); if (cand == 0) { ! if (complain) ! { ! error ("call of `(%T) (%A)' is ambiguous", TREE_TYPE (obj), args); ! print_z_candidates (candidates); ! } return error_mark_node; } *************** build_object_call (tree obj, tree args) *** 2941,2947 **** (TREE_VEC_ELT (cand->convs, 0), obj, cand->fn, -1); /* FIXME */ ! return build_function_call (obj, args); } static void --- 2949,2955 ---- (TREE_VEC_ELT (cand->convs, 0), obj, cand->fn, -1); /* FIXME */ ! return build_function_call (obj, args, complain); } static void *************** build_new_op (enum tree_code code, int f *** 3506,3512 **** abort (); case CALL_EXPR: ! return build_object_call (arg1, arg2); default: break; --- 3514,3520 ---- abort (); case CALL_EXPR: ! return build_object_call (arg1, arg2, true); default: break; *************** build_op_delete_call (enum tree_code cod *** 3910,3916 **** args = tree_cons (NULL_TREE, addr, build_tree_list (NULL_TREE, size)); ! return build_function_call (fn, args); } /* If we are doing placement delete we do nothing if we don't find a --- 3918,3924 ---- args = tree_cons (NULL_TREE, addr, build_tree_list (NULL_TREE, size)); ! return build_function_call (fn, args, true); } /* If we are doing placement delete we do nothing if we don't find a Index: cp/cp-tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v retrieving revision 1.817.4.15 diff -p -r1.817.4.15 cp-tree.h *** cp/cp-tree.h 5 Oct 2003 08:43:08 -0000 1.817.4.15 --- cp/cp-tree.h 7 Oct 2003 10:07:46 -0000 *************** extern bool null_ptr_cst_p (tree); *** 3492,3498 **** extern bool sufficient_parms_p (tree); extern tree type_decays_to (tree); extern tree build_user_type_conversion (tree, tree, int); ! extern tree build_new_function_call (tree, tree); extern tree build_operator_new_call (tree, tree, tree *, tree *); extern tree build_new_method_call (tree, tree, tree, tree, int); extern tree build_special_member_call (tree, tree, tree, tree, int); --- 3492,3498 ---- extern bool sufficient_parms_p (tree); extern tree type_decays_to (tree); extern tree build_user_type_conversion (tree, tree, int); ! extern tree build_new_function_call (tree, tree, bool); extern tree build_operator_new_call (tree, tree, tree *, tree *); extern tree build_new_method_call (tree, tree, tree, tree, int); extern tree build_special_member_call (tree, tree, tree, tree, int); *************** extern void import_export_vtable (tree, *** 3763,3769 **** extern void import_export_decl (tree); extern void import_export_tinfo (tree, tree, bool); extern tree build_cleanup (tree); ! extern tree build_offset_ref_call_from_tree (tree, tree); extern void set_decl_namespace (tree, tree, bool); extern tree current_decl_namespace (void); extern void push_decl_namespace (tree); --- 3763,3769 ---- extern void import_export_decl (tree); extern void import_export_tinfo (tree, tree, bool); extern tree build_cleanup (tree); ! extern tree build_offset_ref_call_from_tree (tree, tree, bool); extern void set_decl_namespace (tree, tree, bool); extern tree current_decl_namespace (void); extern void push_decl_namespace (tree); *************** extern tree begin_stmt_expr *** 4092,4098 **** extern tree finish_stmt_expr_expr (tree); extern tree finish_stmt_expr (tree, bool); extern tree perform_koenig_lookup (tree, tree); ! extern tree finish_call_expr (tree, tree, bool, bool); extern tree finish_increment_expr (tree, enum tree_code); extern tree finish_this_expr (void); extern tree finish_object_call_expr (tree, tree, tree); --- 4092,4098 ---- extern tree finish_stmt_expr_expr (tree); extern tree finish_stmt_expr (tree, bool); extern tree perform_koenig_lookup (tree, tree); ! extern tree finish_call_expr (tree, tree, bool, bool, bool); extern tree finish_increment_expr (tree, enum tree_code); extern tree finish_this_expr (void); extern tree finish_object_call_expr (tree, tree, tree); *************** extern tree build_ptrmemfunc_access_expr *** 4280,4285 **** --- 4280,4286 ---- extern tree build_address (tree); extern tree build_nop (tree, tree); extern tree non_reference (tree); + extern tree build_function_call (tree, tree, bool); /* in typeck2.c */ extern void require_complete_eh_spec_types (tree, tree); Index: cp/decl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v retrieving revision 1.1012.4.10 diff -p -r1.1012.4.10 decl.c *** cp/decl.c 4 Oct 2003 13:54:21 -0000 1.1012.4.10 --- cp/decl.c 7 Oct 2003 10:07:53 -0000 *************** register_dtor_fn (tree decl) *** 8225,8231 **** } else args = tree_cons (NULL_TREE, cleanup, NULL_TREE); ! finish_expr_stmt (build_function_call (get_atexit_node (), args)); } /* DECL is a VAR_DECL with static storage duration. INIT, if present, --- 8225,8231 ---- } else args = tree_cons (NULL_TREE, cleanup, NULL_TREE); ! finish_expr_stmt (build_function_call (get_atexit_node (), args, true)); } /* DECL is a VAR_DECL with static storage duration. INIT, if present, Index: cp/decl2.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v retrieving revision 1.600.4.8 diff -p -r1.600.4.8 decl2.c *** cp/decl2.c 4 Oct 2003 13:54:23 -0000 1.600.4.8 --- cp/decl2.c 7 Oct 2003 10:07:55 -0000 *************** generate_ctor_or_dtor_function (bool con *** 2509,2515 **** NULL_TREE); arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0), arguments); ! finish_expr_stmt (build_function_call (fndecl, arguments)); } } --- 2509,2515 ---- NULL_TREE); arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0), arguments); ! finish_expr_stmt (build_function_call (fndecl, arguments, true)); } } *************** generate_ctor_or_dtor_function (bool con *** 2531,2537 **** { if (! body) body = start_objects (function_key, priority); ! finish_expr_stmt (build_function_call (fndecl, NULL_TREE)); } } } --- 2531,2537 ---- { if (! body) body = start_objects (function_key, priority); ! finish_expr_stmt (build_function_call (fndecl, NULL, true)); } } } *************** finish_file (void) *** 2962,2968 **** They have already been semantically analyzed. */ tree ! build_offset_ref_call_from_tree (tree fn, tree args) { tree orig_fn; tree orig_args; --- 2962,2968 ---- They have already been semantically analyzed. */ tree ! build_offset_ref_call_from_tree (tree fn, tree args, bool complain) { tree orig_fn; tree orig_args; *************** build_offset_ref_call_from_tree (tree fn *** 3008,3014 **** args = tree_cons (NULL_TREE, object_addr, args); } ! expr = build_function_call (fn, args); if (processing_template_decl && expr != error_mark_node) return build_min_non_dep (CALL_EXPR, expr, orig_fn, orig_args); return expr; --- 3008,3014 ---- args = tree_cons (NULL_TREE, object_addr, args); } ! expr = build_function_call (fn, args, complain); if (processing_template_decl && expr != error_mark_node) return build_min_non_dep (CALL_EXPR, expr, orig_fn, orig_args); return expr; Index: cp/except.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/except.c,v retrieving revision 1.153.4.5 diff -p -r1.153.4.5 except.c *** cp/except.c 4 Oct 2003 13:54:24 -0000 1.153.4.5 --- cp/except.c 7 Oct 2003 10:07:56 -0000 *************** do_begin_catch (void) *** 170,177 **** fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } ! return build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), ! NULL_TREE)); } /* Returns nonzero if cleaning up an exception of type TYPE (which can be --- 170,177 ---- fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } ! return build_function_call (fn, tree_cons (NULL, build_exc_ptr (), NULL), ! true); } /* Returns nonzero if cleaning up an exception of type TYPE (which can be *************** do_end_catch (tree type) *** 206,212 **** TREE_NOTHROW (fn) = 0; } ! cleanup = build_function_call (fn, NULL_TREE); TREE_NOTHROW (cleanup) = dtor_nothrow (type); return cleanup; --- 206,212 ---- TREE_NOTHROW (fn) = 0; } ! cleanup = build_function_call (fn, NULL, true); TREE_NOTHROW (cleanup) = dtor_nothrow (type); return cleanup; *************** do_allocate_exception (tree type) *** 503,510 **** fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } ! return build_function_call (fn, tree_cons (NULL_TREE, size_in_bytes (type), ! NULL_TREE)); } #if 0 --- 503,510 ---- fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } ! return build_function_call ! (fn, tree_cons (NULL, size_in_bytes (type), NULL), true); } #if 0 *************** do_free_exception (tree ptr) *** 524,530 **** void_list_node)); } ! return build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE)); } #endif --- 524,530 ---- void_list_node)); } ! return build_function_call (fn, tree_cons (NULL, ptr, NULL), true); } #endif *************** build_throw (tree exp) *** 646,652 **** fn = push_throw_library_fn (fn, tmp); } ! exp = build_function_call (fn, tree_cons (NULL_TREE, exp, NULL_TREE)); } else if (exp) { --- 646,652 ---- fn = push_throw_library_fn (fn, tmp); } ! exp = build_function_call (fn, tree_cons (NULL, exp, NULL), true); } else if (exp) { *************** build_throw (tree exp) *** 752,758 **** tmp = tree_cons (NULL_TREE, throw_type, tmp); tmp = tree_cons (NULL_TREE, ptr, tmp); /* ??? Indicate that this function call throws throw_type. */ ! tmp = build_function_call (fn, tmp); /* Tack on the initialization stuff. */ exp = build (COMPOUND_EXPR, TREE_TYPE (tmp), exp, tmp); --- 752,758 ---- tmp = tree_cons (NULL_TREE, throw_type, tmp); tmp = tree_cons (NULL_TREE, ptr, tmp); /* ??? Indicate that this function call throws throw_type. */ ! tmp = build_function_call (fn, tmp, true); /* Tack on the initialization stuff. */ exp = build (COMPOUND_EXPR, TREE_TYPE (tmp), exp, tmp); *************** build_throw (tree exp) *** 771,777 **** /* ??? Indicate that this function call allows exceptions of the type of the enclosing catch block (if known). */ ! exp = build_function_call (fn, NULL_TREE); } exp = build1 (THROW_EXPR, void_type_node, exp); --- 771,777 ---- /* ??? Indicate that this function call allows exceptions of the type of the enclosing catch block (if known). */ ! exp = build_function_call (fn, NULL, true); } exp = build1 (THROW_EXPR, void_type_node, exp); Index: cp/init.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v retrieving revision 1.311.4.9 diff -p -r1.311.4.9 init.c *** cp/init.c 4 Oct 2003 13:54:24 -0000 1.311.4.9 --- cp/init.c 7 Oct 2003 10:07:57 -0000 *************** build_new_1 (tree exp) *** 2013,2020 **** class_addr = build1 (ADDR_EXPR, jclass_node, class_decl); alloc_call = (build_function_call (alloc_decl, ! tree_cons (NULL_TREE, class_addr, ! build_tree_list (NULL_TREE, class_size)))); } else { --- 2013,2020 ---- class_addr = build1 (ADDR_EXPR, jclass_node, class_decl); alloc_call = (build_function_call (alloc_decl, ! tree_cons (NULL, class_addr, ! build_tree_list (NULL, class_size)), true)); } else { Index: cp/parser.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v retrieving revision 1.48.4.12 diff -p -r1.48.4.12 parser.c *** cp/parser.c 4 Oct 2003 13:54:25 -0000 1.48.4.12 --- cp/parser.c 7 Oct 2003 10:08:04 -0000 *************** cp_parser_postfix_expression (cp_parser *** 3575,3594 **** || TREE_CODE (postfix_expression) == MEMBER_REF || TREE_CODE (postfix_expression) == DOTSTAR_EXPR) postfix_expression = (build_offset_ref_call_from_tree ! (postfix_expression, args)); else if (idk == CP_ID_KIND_QUALIFIED) /* A call to a static class member, or a namespace-scope function. */ postfix_expression = finish_call_expr (postfix_expression, args, /*disallow_virtual=*/true, ! koenig_p); else /* All other function calls. */ postfix_expression = finish_call_expr (postfix_expression, args, /*disallow_virtual=*/false, ! koenig_p); /* The POSTFIX_EXPRESSION is certainly no longer an id. */ idk = CP_ID_KIND_NONE; --- 3575,3594 ---- || TREE_CODE (postfix_expression) == MEMBER_REF || TREE_CODE (postfix_expression) == DOTSTAR_EXPR) postfix_expression = (build_offset_ref_call_from_tree ! (postfix_expression, args, true)); else if (idk == CP_ID_KIND_QUALIFIED) /* A call to a static class member, or a namespace-scope function. */ postfix_expression = finish_call_expr (postfix_expression, args, /*disallow_virtual=*/true, ! koenig_p, true); else /* All other function calls. */ postfix_expression = finish_call_expr (postfix_expression, args, /*disallow_virtual=*/false, ! koenig_p, true); /* The POSTFIX_EXPRESSION is certainly no longer an id. */ idk = CP_ID_KIND_NONE; Index: cp/pt.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v retrieving revision 1.669.4.13 diff -p -r1.669.4.13 pt.c *** cp/pt.c 4 Oct 2003 13:54:28 -0000 1.669.4.13 --- cp/pt.c 7 Oct 2003 10:08:09 -0000 *************** tsubst_copy_and_build (tree t, *** 8165,8171 **** 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) return (build_new_method_call (TREE_OPERAND (function, 0), --- 8165,8172 ---- function = convert_from_reference (function); if (TREE_CODE (function) == OFFSET_REF) ! return build_offset_ref_call_from_tree ! (function, call_args, complain & tf_error); if (TREE_CODE (function) == COMPONENT_REF) return (build_new_method_call (TREE_OPERAND (function, 0), *************** tsubst_copy_and_build (tree t, *** 8174,8180 **** qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL)); return finish_call_expr (function, call_args, /*disallow_virtual=*/qualified_p, ! koenig_p); } case COND_EXPR: --- 8175,8181 ---- qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL)); return finish_call_expr (function, call_args, /*disallow_virtual=*/qualified_p, ! koenig_p, complain & tf_error); } case COND_EXPR: Index: cp/semantics.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v retrieving revision 1.298.4.14 diff -p -r1.298.4.14 semantics.c *** cp/semantics.c 5 Oct 2003 18:41:45 -0000 1.298.4.14 --- cp/semantics.c 7 Oct 2003 10:08:10 -0000 *************** perform_koenig_lookup (tree fn, tree arg *** 1586,1592 **** Returns code for the call. */ tree ! finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) { tree result; tree orig_fn; --- 1586,1593 ---- Returns code for the call. */ tree ! finish_call_expr (tree fn, tree args, bool disallow_virtual, ! bool koenig_p, bool complain) { tree result; tree orig_fn; *************** finish_call_expr (tree fn, tree args, bo *** 1690,1699 **** } else if (is_overloaded_fn (fn)) /* A call to a namespace-scope function. */ ! result = build_new_function_call (fn, args); else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR) { ! if (args) error ("arguments to destructor are not allowed"); /* Mark the pseudo-destructor call as having side-effects so that we do not issue warnings about its use. */ --- 1691,1700 ---- } else if (is_overloaded_fn (fn)) /* A call to a namespace-scope function. */ ! result = build_new_function_call (fn, args, complain); else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR) { ! if (args && complain) error ("arguments to destructor are not allowed"); /* Mark the pseudo-destructor call as having side-effects so that we do not issue warnings about its use. */ *************** finish_call_expr (tree fn, tree args, bo *** 1708,1714 **** result = build_new_op (CALL_EXPR, LOOKUP_NORMAL, fn, args, NULL_TREE); if (!result) /* A call where the function is unknown. */ ! result = build_function_call (fn, args); if (processing_template_decl) { --- 1709,1718 ---- result = build_new_op (CALL_EXPR, LOOKUP_NORMAL, fn, args, NULL_TREE); if (!result) /* A call where the function is unknown. */ ! result = build_function_call (fn, args, complain); ! ! if (result == error_mark_node) ! return error_mark_node; if (processing_template_decl) { Index: cp/typeck.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v retrieving revision 1.451.4.10 diff -p -r1.451.4.10 typeck.c *** cp/typeck.c 5 Oct 2003 08:43:08 -0000 1.451.4.10 --- cp/typeck.c 7 Oct 2003 10:08:13 -0000 *************** get_member_function_from_ptrfunc (tree * *** 2340,2346 **** } tree ! build_function_call (tree function, tree params) { register tree fntype, fndecl; register tree coerced_params; --- 2340,2346 ---- } tree ! build_function_call (tree function, tree params, bool complain) { register tree fntype, fndecl; register tree coerced_params; *************** build_function_call (tree function, tree *** 2364,2370 **** fndecl = function; /* Convert anything with function type to a pointer-to-function. */ ! if (pedantic && DECL_MAIN_P (function)) pedwarn ("ISO C++ forbids calling `::main' from within program"); /* Differs from default_conversion by not setting TREE_ADDRESSABLE --- 2364,2370 ---- fndecl = function; /* Convert anything with function type to a pointer-to-function. */ ! if (pedantic && DECL_MAIN_P (function) && complain) pedwarn ("ISO C++ forbids calling `::main' from within program"); /* Differs from default_conversion by not setting TREE_ADDRESSABLE *************** build_function_call (tree function, tree *** 2388,2394 **** fntype = TREE_TYPE (function); ! if (TYPE_PTRMEMFUNC_P (fntype)) { error ("must use .* or ->* to call pointer-to-member function in `%E (...)'", original); --- 2388,2394 ---- fntype = TREE_TYPE (function); ! if (TYPE_PTRMEMFUNC_P (fntype) && complain) { error ("must use .* or ->* to call pointer-to-member function in `%E (...)'", original); *************** build_function_call (tree function, tree *** 2403,2409 **** || is_method || TREE_CODE (function) == TEMPLATE_ID_EXPR)) { ! error ("`%E' cannot be used as a function", original); return error_mark_node; } --- 2403,2410 ---- || is_method || TREE_CODE (function) == TEMPLATE_ID_EXPR)) { ! if (complain) ! error ("`%E' cannot be used as a function", original); return error_mark_node; }
Attachment:
decltype.cpp
Description: Text document
Attachment:
bind.cpp
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |