aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-10-17 18:42:27 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-10-17 18:42:27 +0000
commitf406ae1fd66cbef7528139d813049d606973b4d2 (patch)
treeffce8e64d878ee05289269f4a519e7d104d3fd94
parent92574c7cdbf3f32fdc48897990d63e1dc65d5bbf (diff)
downloadgcc-f406ae1fd66cbef7528139d813049d606973b4d2.zip
gcc-f406ae1fd66cbef7528139d813049d606973b4d2.tar.gz
gcc-f406ae1fd66cbef7528139d813049d606973b4d2.tar.bz2
re PR c/63549 ([4.8/4.9/5] ICE in build_array_ref with invalid code)
PR c/63549 * c-typeck.c (build_array_ref): Bail if the index in an incomplete type. * gcc.dg/pr63549.c: New test. From-SVN: r216413
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr63549.c7
4 files changed, 20 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index d6a58a8..bb57ee2 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,11 @@
2014-10-17 Marek Polacek <polacek@redhat.com>
+ PR c/63549
+ * c-typeck.c (build_array_ref): Bail if the index in an incomplete
+ type.
+
+2014-10-17 Marek Polacek <polacek@redhat.com>
+
* c-decl.c (grokdeclarator): Use OPT_Wimplicit_int unconditionally.
(start_function): Use OPT_Wimplicit_int instead of 0.
(store_parm_decls_oldstyle): Likewise.
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 5c0697a..1e971c1 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2478,6 +2478,8 @@ build_array_ref (location_t loc, tree array, tree index)
/* Apply default promotions *after* noticing character types. */
index = default_conversion (index);
+ if (index == error_mark_node)
+ return error_mark_node;
gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a73dad9..f9e3458 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2014-10-17 Marek Polacek <polacek@redhat.com>
+ PR c/63549
+ * gcc.dg/pr63549.c: New test.
+
+2014-10-17 Marek Polacek <polacek@redhat.com>
+
* gcc.dg/Wimplicit-int-1.c: New test.
* gcc.dg/Wimplicit-int-2.c: New test.
* gcc.dg/Wimplicit-int-3.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr63549.c b/gcc/testsuite/gcc.dg/pr63549.c
new file mode 100644
index 0000000..c9b1718
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr63549.c
@@ -0,0 +1,7 @@
+/* PR c/63549 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+enum E e;
+int a[10];
+int i = a[e]; /* { dg-error "has an incomplete type" } */