aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-05-06 11:02:26 -0700
committerJim Wilson <wilson@gcc.gnu.org>1993-05-06 11:02:26 -0700
commitea8dd78442e6119d42dcd7bbcc18b322497d1f59 (patch)
tree0f24d3e508ff40b1a5b9c217d41e1261d4927bd0 /gcc
parent9ea0a7533cf9d9727fbb6c8d606c67da145c2572 (diff)
downloadgcc-ea8dd78442e6119d42dcd7bbcc18b322497d1f59.zip
gcc-ea8dd78442e6119d42dcd7bbcc18b322497d1f59.tar.gz
gcc-ea8dd78442e6119d42dcd7bbcc18b322497d1f59.tar.bz2
(pointer_diff): Error if op1 is pointer to incomplete type.
From-SVN: r4367
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 088e877..2e3b018 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2944,6 +2944,10 @@ pointer_diff (op0, op1)
op0 = build_binary_op (MINUS_EXPR, convert (restype, op0),
convert (restype, op1), 1);
+ /* This generates an error if op1 is pointer to incomplete type. */
+ if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0)
+ error ("arithmetic on pointer to an incomplete type");
+ /* This generates an error if op0 is pointer to incomplete type. */
op1 = c_size_in_bytes (target_type);
/* Divide by the size, in easiest possible way. */