aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-01-29 00:05:21 +0000
committerTom Tromey <tromey@redhat.com>2008-01-29 00:05:21 +0000
commitcd017dabdec884da739c5113b67c75cca8469110 (patch)
treea4d00d0581917616b5643bec8c09d6519523d1b9
parente2b9d5bbb8cdf3b2794ff384b154cd72079a72cd (diff)
* c-typeck.c (build_array_ref): Wrap pointer in
VIEW_CONVERT_EXPR. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/incremental-compiler@131924 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c11
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9ee83ed6bab..61d29c2a011 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-28 Tom Tromey <tromey@redhat.com>
+
+ * c-typeck.c (build_array_ref): Wrap pointer in
+ VIEW_CONVERT_EXPR.
+
2008-01-23 Tom Tromey <tromey@redhat.com>
* c-parser.c (c_parse_file_wrapper): Only save jobs with names.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 1ceb2ebff06..b4c91efee3b 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1,6 +1,6 @@
/* Build expressions with type checking for C compiler.
Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GCC.
@@ -2066,6 +2066,7 @@ build_array_ref (tree array, tree index)
else
{
tree ar = default_conversion (array);
+ tree t2;
if (ar == error_mark_node)
return ar;
@@ -2073,6 +2074,14 @@ build_array_ref (tree array, tree index)
gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
+ t2 = C_SMASHED_TYPE_VARIANT (TREE_TYPE (TREE_TYPE (ar)));
+ if (t2 != TREE_TYPE (TREE_TYPE (ar)))
+ {
+ int sf = TREE_SIDE_EFFECTS (ar);
+ ar = build1 (VIEW_CONVERT_EXPR, build_pointer_type (t2), ar);
+ TREE_SIDE_EFFECTS (ar) = sf;
+ }
+
return build_indirect_ref (build_binary_op (PLUS_EXPR, ar, index, 0),
"array indexing");
}