summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-22 09:40:13 +0000
committerkyukhin <kyukhin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-22 09:40:13 +0000
commit12c66f2f15b8b90ef2be8ec2e9e56ca9790fd25d (patch)
treec3112ea389064e5daa4b71fbea724f0791573f93
parent4f3ec923dd848da3be68c9e2b422d268f2f3587d (diff)
downloadppe42-gcc-12c66f2f15b8b90ef2be8ec2e9e56ca9790fd25d.tar.gz
ppe42-gcc-12c66f2f15b8b90ef2be8ec2e9e56ca9790fd25d.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@214306 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c7
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cp-array-notation.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/AN/pr62008.c10
6 files changed, 38 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index f475f7ea16e..6fb49c62c62 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-22 Igor Zamyatin <igor.zamyatin@intel.com>
+
+ PR other/62008
+ * c-parser.c (c_parser_array_notation): Check for correct
+ type of an array added.
+
2014-08-01 Igor Zamyatin <igor.zamyatin@intel.com>
PR middle-end/61455
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index a51af2e305d..6ce277c9b0b 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -14074,6 +14074,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 88a3c9b8d3c..bb1068e0b2c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-22 Igor Zamyatin <igor.zamyatin@intel.com>
+
+ PR other/62008
+ * cp-array-notation.c (build_array_notation_ref): Added correct
+ handling of case with incorrect array.
+
2014-08-19 Jason Merrill <jason@redhat.com>
PR c++/61214
diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
index de9cc401249..a50ff1dc9af 100644
--- a/gcc/cp/cp-array-notation.c
+++ b/gcc/cp/cp-array-notation.c
@@ -1403,7 +1403,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 09147bec7f0..5033c327c56 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-22 Igor Zamyatin <igor.zamyatin@intel.com>
+
+ PR other/62008
+ * c-c++-common/cilk-plus/AN/pr62008.c: New test.
+
2014-08-21 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
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 } */
+}
OpenPOWER on IntegriCloud