aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorBalaji V. Iyer <balaji.v.iyer@intel.com>2013-06-28 20:04:36 +0000
committerBalaji V. Iyer <bviyer@gcc.gnu.org>2013-06-28 13:04:36 -0700
commit1141ed3f71c8a82067dbbbed6ec87c607bfd0be9 (patch)
treeb185d91a0ad09f83a8b64c2047d429fd12c60efe /gcc/cp/call.c
parente32e4c4a8826f872814b58deba660f6bb31e7b21 (diff)
downloadgcc-1141ed3f71c8a82067dbbbed6ec87c607bfd0be9.zip
gcc-1141ed3f71c8a82067dbbbed6ec87c607bfd0be9.tar.gz
gcc-1141ed3f71c8a82067dbbbed6ec87c607bfd0be9.tar.bz2
Implemented Jason Merrill's suggestions on Array Notation C++.
gcc/ChangeLog 2013-06-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * builtins.def: Fixed the function type of CILKPLUS_BUILTIN. gcc/c/ChangeLog 2013-06-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-parser.c (c_parser_array_notation): Removed rejection of array notations in an array of function pointers. gcc/c-family/ChangeLog 2013-06-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * array-notation-common.c (length_mismatch_in_expr_p): Collapsed two if-statements and compared the trees directly using tree_int_cst_equal. (find_rank): Checked for array notations in function name to handle array notations in function pointers. (extract_array_notation_exprs): Likewise. (replace_array_notations): Likewise. (cilkplus_extract_an_triplets): Replaced safe_push with safe_grow_cleared. Also removed an unnecessary check to see if the node is of type ARRAY_NOTATION_REF. (fix_sec_implicit_args): Removed an unnecessary check for ADDR_EXPR. Also switched two if-statements to remove an unnecessary comparison. gcc/cp/ChangeLog 2013-06-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * parser.c (cp_parser_array_notation): Removed rejection array notation of type function pointers. Added handling of array expressions when Cilk Plus is enabled. Took out type-checking. (cp_parser_postfix_open_square_expression): Moved normal array expr. parsing into cp_parser_array_notation when cilkplus is enabled. (cp_parser_compound_statement): Removed expansion of array notations. (cp_parser_ctor_initializer_opt_and_function_body): Likewise. (cp_parser_function_definition_after_declarator): Likewise. (cp_parser_selection_statement): Removed error reporting. (cp_parser_iteration_statement): Likewise. (cp_parser_direct_declarator): Removed error checking/reporting if array notations are used in the declarator. * pt.c (instantiate_decl): Likewise. (type_unification_real): Removed a check for ARRAY_NOTATION_REF. (cxx_eval_constant_expression): Removed ARRAY_NOTATION_REF case. (potential_constant_expression_1): Returned false for ARRAY_NOTATION_REF case. * cp-gimplify.c (cp_genericize): Added expansion of array notation expressions here. * cp-array-notation.c (make_triplet_val_inv): Removed loc and cry parameters. Replaced build_decls with get_temp_regvar with type as ptrdiff. (create_array_refs): Made the type-casting to ptrdiff_type. (replace_invariant_var): Added a check for void return type before creating new var. Replaced build_decl and build_min_nt_loc with get_temp_regvar. (expand_an_in_modify_expr): Ditto. Replaced body of redundant else with gcc_unreachable. Removed few unwanted checks. Made induction variable type as ptrdiff_type. Removed loc and complain arguments passed into make_triplet_val_inv. Replaced all modify expression's code from NOP EXPR to INIT EXPR. Replaced all forceful appending into stmt. list with the non-forceful one. Replaced some integer conversion and equality-checking to using tree_int_cst_equal. (expand_sec_reduce_builtin): All changes mentioned in above function expand_an_in_modify_expr. Made the new variable type of SEC_REDUCE_ANY/ALL_{NON}ZERO intrinsic functions as bool. (expand_array_notation_exprs): Removed SWITCH_EXPR case. Moved all the error reporting from parser to this function. Removed unwanted statements and checks from SWITCH_STMT, WHILE_STMT, and DO_STMT cases. (cilkplus_an_triplet_types_ok_p): Removed rejection of array notation in function pointers. (cp_expand_cond_array_notations): Added a new if statements to check if condition has a zero rank. If so, then just return. (expand_return_expr): Added a check for return expressions with a rank. Replaced get_tmp_regvar with a create_temporary_var. (build_array_notation_ref): Simplified and removed unwanted if-stmts. Moved common code outside if-statements. Moved type-checking from parser to here. * semantics.c (finish_return_stmt): Removed a check for return exprs. with a rank. * call.c (convert_like_real): Removed a check for array notation expression in a function. (build_over_call): Likewise. (magic_varargs_p): Added a check for builtin array notation function. Made this function non-static and removed its prototype. * cp-tree.h (magic_varargs_p): New prototype. * typeck.c (cp_build_function_call_vec): Removed automatic setting of nargs to the param->length when builtin reduction function is used. (convert_arguments): Replaced check for a constant_p function with margic_varargs_p function call. (cp_build_binary_op): Removed calling of the function find_correct_array_notation_type. (cp_build_addr_expr_1): Removed an unwanted if-statement. (convert_for_assignment): Removed automatic return of rhs when array notation builtin function is used. gcc/testsuite/ChangeLog 2013-06-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-c++-common/cilk-plus/AN/decl-ptr-colon.c (main): Made this testcase c specific. * c-c++-common/cilk-plus/AN/decl-ptr-colon.c (main): Changed dg-error strings to match the fixed error messages. * c-c++-common/cilk-plus/AN/misc.c (main): Likewise. * c-c++-common/cilk-plus/AN/rank_mismatch.c (main): Added a new error message check. From-SVN: r200554
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 6817bfc..425ef9b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -216,7 +216,6 @@ static void add_candidates (tree, tree, const vec<tree, va_gc> *, tree, tree,
bool, tree, tree, int, struct z_candidate **,
tsubst_flags_t);
static conversion *merge_conversion_sequences (conversion *, conversion *);
-static bool magic_varargs_p (tree);
static tree build_temp (tree, tree, int, diagnostic_t *, tsubst_flags_t);
/* Returns nonzero iff the destructor name specified in NAME matches BASETYPE.
@@ -5857,16 +5856,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
else if (t->kind == ck_identity)
break;
}
-
- if (flag_enable_cilkplus
- && (contains_array_notation_expr (expr)
- || contains_array_notation_expr (fn)))
- /* If we are using array notations, we fix them up at a later stage
- and we will do these checks then. */
- ;
- else if (permerror (loc, "invalid conversion from %qT to %qT",
- TREE_TYPE (expr), totype)
- && fn)
+ if (permerror (loc, "invalid conversion from %qT to %qT",
+ TREE_TYPE (expr), totype)
+ && fn)
inform (DECL_SOURCE_LOCATION (fn),
"initializing argument %P of %qD", argnum, fn);
@@ -6515,9 +6507,12 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
which no conversions at all should be done. This is true for some
builtins which don't act like normal functions. */
-static bool
+bool
magic_varargs_p (tree fn)
{
+ if (flag_enable_cilkplus && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE)
+ return true;
+
if (DECL_BUILT_IN (fn))
switch (DECL_FUNCTION_CODE (fn))
{
@@ -6895,21 +6890,13 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
" (you can disable this with -fno-deduce-init-list)");
}
}
+ val = convert_like_with_context (conv, arg, fn, i - is_method,
+ conversion_warning
+ ? complain
+ : complain & (~tf_warning));
- /* If the function call is builtin array notation function then no need
- to do any type conversion. */
- if (flag_enable_cilkplus
- && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE)
- val = arg;
- else
- {
- val = convert_like_with_context (conv, arg, fn, i - is_method,
- conversion_warning
- ? complain
- : complain & (~tf_warning));
-
- val = convert_for_arg_passing (type, val, complain);
- }
+ val = convert_for_arg_passing (type, val, complain);
+
if (val == error_mark_node)
return error_mark_node;
else