From: Igor Zamyatin Date: Fri, 22 Aug 2014 09:37:01 +0000 (+0000) Subject: re PR other/62008 (CilkPlus Array Notation ICE in build_array_notation_ref when tryin... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=671a475e64d77f16b3fbc5aad349be68828c1318;p=gcc.git re PR other/62008 (CilkPlus Array Notation ICE in build_array_notation_ref when trying to build a multidimensional array from a pointer.) PR other/62008 gcc/c/ * c-parser.c (c_parser_array_notation): Check for correct type of an array added. gcc/cp/ * cp-array-notation.c (build_array_notation_ref): Added correct handling of case with incorrect array. gcc/testsuite/ * c-c++-common/cilk-plus/AN/pr62008.c: New test. From-SVN: r214305 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e5429ac617c..77bc05bbcca 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-08-22 Igor Zamyatin + + PR other/62008 + * c-parser.c (c_parser_array_notation): Check for correct + type of an array added. + 2014-08-19 Marek Polacek PR c++/62153 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d5887972088..d634bb1795f 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -14170,6 +14170,13 @@ c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index, array_type = TREE_TYPE (array_value); gcc_assert (array_type); + if (TREE_CODE (array_type) != ARRAY_TYPE + && TREE_CODE (array_type) != POINTER_TYPE) + { + error_at (loc, "base of array section must be pointer or array type"); + c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); + return error_mark_node; + } type = TREE_TYPE (array_type); token = c_parser_peek_token (parser); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 27e22497357..8505e9c8279 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-08-22 Igor Zamyatin + + PR other/62008 + * cp-array-notation.c (build_array_notation_ref): Added correct + handling of case with incorrect array. + 2014-08-21 Manuel López-Ibáñez PR fortran/44054 diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 6b910fc3a76..20f741aaebc 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -1404,7 +1404,10 @@ build_array_notation_ref (location_t loc, tree array, tree start, tree length, if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == POINTER_TYPE) TREE_TYPE (array_ntn_expr) = TREE_TYPE (type); else - gcc_unreachable (); + { + error_at (loc, "base of array section must be pointer or array type"); + return error_mark_node; + } SET_EXPR_LOCATION (array_ntn_expr, loc); return array_ntn_expr; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da526bfc331..92b9c9e8c9b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-08-22 Igor Zamyatin + + PR other/62008 + * c-c++-common/cilk-plus/AN/pr62008.c: New test. + 2014-08-22 Tony Wang * g++.dg/tls/thread_local6.C: Skip this test case when target uses diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr62008.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr62008.c new file mode 100644 index 00000000000..05734c56017 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr62008.c @@ -0,0 +1,10 @@ +/* PR other/62008 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +void f(int *a, int w, int h) +{ + int tmp[w][h]; + tmp[:][:] = a[0:w][0:h]; /* { dg-error "base of array section must be pointer or array type" } */ + /* { dg-error "start-index and length fields necessary" "" { target c } 8 } */ +}