diff options
author | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-21 19:36:47 +0000 |
---|---|---|
committer | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-21 19:36:47 +0000 |
commit | e9331eab2ce587332e64892fb622583ace8b512d (patch) | |
tree | e7207dc359e56d6ee18d5ceeab12e6a330340857 /gcc/cp/typeck.c | |
parent | 2511e9f1e8549ef8fc461b8c35440c27d0b8a63f (diff) | |
download | ppe42-gcc-e9331eab2ce587332e64892fb622583ace8b512d.tar.gz ppe42-gcc-e9331eab2ce587332e64892fb622583ace8b512d.zip |
Implemented Cilk Plus Array Notation for C++
gcc/c-family/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-common.h (struct cilkplus_an_parts): New structure.
(struct cilkplus_an_loop_parts): Likewise.
(cilkplus_extract_an_triplets): New prototype.
(fix_sec_implicit_args): Likewise.
* array-notation-common.c (cilkplus_extract_an_triplets): New function.
(fix_sec_implicit_args): Likewise.
gcc/cp/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* call.c (convert_like_real): Added a check if array notation is present
in expression. If so, then no conversion of arguments is necessary.
(build_over_call): Likewise.
* typeck.c (cp_build_function_call_vec): Likewise.
(convert_for_assignment): Likewise.
(cp_build_array_ref): Reject array notations with a rank greater than 1
as an array's index.
(cp_build_binary_op): If array notations are preent in op, then call
find_correct_array_notation_type.
(cp_build_addr_expr_1): Handle ARRAY_NOTATION_REF similar to ARRAY_REF.
* cp-array-notation.c: New file.
* cp-objcp-common.c (cp_common_init_ts): Marked ARRAY_NOTATION_REF tree
as typed.
* cp-tree.h (fix_array_notation_exprs): New prototype.
* semantics.c (finish_return_stmt): Reject array notations as
return value.
(cxx_eval_constant_expression): Added ARRAY_NOTATION_REF case.
(potential_constant_expression_1): Likewise.
* tree.c (lvalue_kind): Likewise.
* error.c (dump_decl): Likewise.
(dump_expr): Likewise.
* pt.c (ARRAY_NOTATION_REF): Likewise.
(type_unification_real): Do not unify any arguments if array notations
are found in arg.
(instantiate_decl): Added a check for array notaitons inside the
function body. If so, then expand them.
* parser.c (cp_parser_array_notation): New function.
(cp_parser_postfix_open_square_expression): Added a check for colons
inside square braces. If found, then handle the array access as an
array notation access. Also, disable auto-correction from a single
colon to scope when Cilk Plus is enabled.
(cp_parser_compound_statement): Added a check for array notations
inside the statement. If found, then expand them.
(cp_parser_ctor_initializer_opt_and_function_body): Likewise.
(cp_parser_function_definition_after_declarator): Likewise.
(cp_parser_selection_statement): Searched for array notations inside
condition. If so, then emit an error.
(cp_parser_iteration_statement): Likewise.
(cp_parser_direct_declarator): Reject array notations inside a
variable or array declaration.
* Make-lang.in (CXX_AND_OBJCXX_OBJS): Added cp/cp-array-notation.o.
gcc/testsuite/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-c++-common/cilk-plus/AN/array_test1.c: Make this an execution test.
Also changed the returns from error as distinct values so that debugging
can get easier.
* c-c++-common/cilk-plus/AN/if_test_errors.c (main): Made certain
errors specific to C, if necessary. Also added new error hooks for C++.
* c-c++-common/cilk-plus/AN/misc.c (main): Likewise.
* c-c++-common/cilk-plus/AN/parser_errors.c (main): Likewise.
* c-c++-common/cilk-plus/AN/parser_errors2.c (main): Likewise.
* c-c++-common/cilk-plus/AN/parser_errors3.c (main): Likewise.
* c-c++-common/cilk-plus/AN/pr57541.c (main): Likewise.
* c-c++-common/cilk-plus/AN/parser_errors4.c (main): In addition to the
same changes as parser_errors3.c, spaces were added between colons to
not confuse C++ compiler with 2 colons as scope.
* c-c++-common/cilk-plus/AN/vla.c: Make this test C specific.
* g++.dg/cilk-plus/AN/array_test1_tplt.cc: New test.
* g++.dg/cilk-plus/AN/array_test2_tplt.cc: Likewise.
* g++.dg/cilk-plus/AN/array_test_ND_tplt.cc: Likewise.
* g++.dg/cilk-plus/AN/braced_list.cc: Likewise.
* g++.dg/cilk-plus/AN/builtin_fn_custom_tplt.cc: Likewise.
* g++.dg/cilk-plus/AN/builtin_fn_mutating_tplt.cc: Likewise.
* g++.dg/cilk-plus/AN/fp_triplet_values_tplt.c: Likewise.
* g++.dg/cilk-plus/AN/preincr_test.cc: Likewise.
* g++.dg/cilk-plus/AN/postincr_test.cc: Likewise.
* g++.dg/cilk-plus/cilk-plus.exp: New script.
* gcc/testsuite/g++.dg/dg.exp: Included Cilk Plus C++ tests in the list.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200319 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 11ac85b65cd..316a657d924 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3005,6 +3005,22 @@ cp_build_array_ref (location_t loc, tree array, tree idx, return error_mark_node; } + /* If an array's index is an array notation, then its rank cannot be + greater than one. */ + if (flag_enable_cilkplus && contains_array_notation_expr (idx)) + { + size_t rank = 0; + + /* If find_rank returns false, then it should have reported an error, + thus it is unnecessary for repetition. */ + if (!find_rank (loc, idx, idx, true, &rank)) + return error_mark_node; + if (rank > 1) + { + error_at (loc, "rank of the array%'s index is greater than 1"); + return error_mark_node; + } + } if (TREE_TYPE (array) == error_mark_node || TREE_TYPE (idx) == error_mark_node) return error_mark_node; @@ -3477,8 +3493,12 @@ cp_build_function_call_vec (tree function, vec<tree, va_gc> **params, params = &allocated; } - nargs = convert_arguments (parm_types, params, fndecl, LOOKUP_NORMAL, - complain); + if (flag_enable_cilkplus + && is_cilkplus_reduce_builtin (fndecl) != BUILT_IN_NONE) + nargs = (*params)->length (); + else + nargs = convert_arguments (parm_types, params, fndecl, LOOKUP_NORMAL, + complain); if (nargs < 0) return error_mark_node; @@ -3936,8 +3956,15 @@ cp_build_binary_op (location_t location, } } - type0 = TREE_TYPE (op0); - type1 = TREE_TYPE (op1); + if (flag_enable_cilkplus && contains_array_notation_expr (op0)) + type0 = find_correct_array_notation_type (op0); + else + type0 = TREE_TYPE (op0); + + if (flag_enable_cilkplus && contains_array_notation_expr (op1)) + type1 = find_correct_array_notation_type (op1); + else + type1 = TREE_TYPE (op1); /* The expression codes of the data types of the arguments tell us whether the arguments are integers, floating, pointers, etc. */ @@ -5140,6 +5167,13 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) gcc_assert (!identifier_p (arg) || !IDENTIFIER_OPNAME_P (arg)); + if (flag_enable_cilkplus && TREE_CODE (arg) == ARRAY_NOTATION_REF) + { + val = build_address (arg); + if (TREE_CODE (arg) == OFFSET_REF) + PTRMEM_OK_P (val) = PTRMEM_OK_P (arg); + return val; + } if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg) && !really_overloaded_fn (TREE_OPERAND (arg, 1))) { @@ -7818,6 +7852,13 @@ convert_for_assignment (tree type, tree rhs, tree rhstype; enum tree_code coder; + /* If we are dealing with built-in array notation function then we don't need + to convert them. They will be broken up into modify exprs in future, + during which all these checks will be done. */ + if (flag_enable_cilkplus + && is_cilkplus_reduce_builtin (fndecl) != BUILT_IN_NONE) + return rhs; + /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */ if (TREE_CODE (rhs) == NON_LVALUE_EXPR) rhs = TREE_OPERAND (rhs, 0); |