Commit f406ae1f by Marek Polacek Committed by Marek Polacek

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
parent 92574c7c
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.
......
......@@ -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);
......
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.
......
/* PR c/63549 */
/* { dg-do compile } */
/* { dg-options "" } */
enum E e;
int a[10];
int i = a[e]; /* { dg-error "has an incomplete type" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment