[llvm-commits] [llvm-gcc-4.2] r102957 - /llvm-gcc-4.2/trunk/gcc/c-typeck.c
Stuart Hastings
stuart at apple.com
Mon May 3 14:28:37 PDT 2010
Author: stuart
Date: Mon May 3 16:28:36 2010
New Revision: 102957
URL: http://llvm.org/viewvc/llvm-project?rev=102957&view=rev
Log:
Diagnose and avoid ICE for 'extern int bar[]; &(&bar)[0] == 0;'. Radar 7216288.
Modified:
llvm-gcc-4.2/trunk/gcc/c-typeck.c
Modified: llvm-gcc-4.2/trunk/gcc/c-typeck.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-typeck.c?rev=102957&r1=102956&r2=102957&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-typeck.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-typeck.c Mon May 3 16:28:36 2010
@@ -2137,6 +2137,14 @@
|| TREE_CODE(ty) == QUAL_UNION_TYPE)
ty = TYPE_MAIN_VARIANT (ty);
+ if (TYPE_SIZE_UNIT (ty) == 0) {
+ /* We don't know the size of the array elements, so we can't
+ index it. Invoke the usual GCC routine; it will diagnose
+ the error and return a tree that won't ICE. */
+ return build_indirect_ref (build_binary_op (PLUS_EXPR, ar, index, 0),
+ "array indexing");
+ }
+
ar = build4 (ARRAY_REF, ty, ar, index, NULL_TREE, NULL_TREE);
/* Mirror logic from build_indirect_ref to set TREE_THIS_VOLATILE and
* other flags.
More information about the llvm-commits
mailing list