aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/c/c-array-notation.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/c/c-array-notation.c')
-rw-r--r--gcc-4.9/gcc/c/c-array-notation.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc-4.9/gcc/c/c-array-notation.c b/gcc-4.9/gcc/c/c-array-notation.c
index 0ac6ba8e1..2305e1e03 100644
--- a/gcc-4.9/gcc/c/c-array-notation.c
+++ b/gcc-4.9/gcc/c/c-array-notation.c
@@ -214,6 +214,13 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
if (an_type == BUILT_IN_NONE)
return NULL_TREE;
+ /* Builtin call should contain at least one argument. */
+ if (call_expr_nargs (an_builtin_fn) == 0)
+ {
+ error_at (EXPR_LOCATION (an_builtin_fn), "Invalid builtin arguments");
+ return error_mark_node;
+ }
+
if (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE
|| an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)
{
@@ -229,6 +236,8 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
/* Fully fold any EXCESSIVE_PRECISION EXPR that can occur in the function
parameter. */
func_parm = c_fully_fold (func_parm, false, NULL);
+ if (func_parm == error_mark_node)
+ return error_mark_node;
location = EXPR_LOCATION (an_builtin_fn);
@@ -236,7 +245,10 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
return error_mark_node;
if (rank == 0)
- return an_builtin_fn;
+ {
+ error_at (location, "Invalid builtin arguments");
+ return error_mark_node;
+ }
else if (rank > 1
&& (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND
|| an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND))
@@ -308,7 +320,9 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
|| an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND)
array_ind_value = build_decl (location, VAR_DECL, NULL_TREE,
TREE_TYPE (func_parm));
- array_op0 = (*array_operand)[0];
+ array_op0 = (*array_operand)[0];
+ if (TREE_CODE (array_op0) == INDIRECT_REF)
+ array_op0 = TREE_OPERAND (array_op0, 0);
switch (an_type)
{
case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: