From ea8dd78442e6119d42dcd7bbcc18b322497d1f59 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Thu, 6 May 1993 11:02:26 -0700 Subject: (pointer_diff): Error if op1 is pointer to incomplete type. From-SVN: r4367 --- gcc/c-typeck.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc') 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. */ -- cgit v1.1