diff options
author | Richard Stallman <rms@gnu.org> | 1993-03-02 03:07:56 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-03-02 03:07:56 +0000 |
commit | 6bc4e3d04fe7c451bc0ded9f60ef70f96a732ebf (patch) | |
tree | 25c76b46460933a7a095ec20f5cc7b21215d1884 | |
parent | 429819203e1a237e28bda2c99c0a49d5501590e2 (diff) | |
download | gcc-6bc4e3d04fe7c451bc0ded9f60ef70f96a732ebf.zip gcc-6bc4e3d04fe7c451bc0ded9f60ef70f96a732ebf.tar.gz gcc-6bc4e3d04fe7c451bc0ded9f60ef70f96a732ebf.tar.bz2 |
(build_unary_op): Warn if increment `struct unknown *'.
From-SVN: r3585
-rw-r--r-- | gcc/c-typeck.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 68c6679..6f20048 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3014,9 +3014,16 @@ build_unary_op (code, xarg, noconvert) if (typecode == POINTER_TYPE) { - if ((pedantic || warn_pointer_arith) - && (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)) + /* If pointer target is an undefined struct, + we just cannot know how to do the arithmetic. */ + if (TYPE_SIZE (TREE_TYPE (result_type)) == 0) + error ("%s of pointer to unknown structure", + ((code == PREINCREMENT_EXPR + || code == POSTINCREMENT_EXPR) + ? "increment" : "decrement")); + else if ((pedantic || warn_pointer_arith) + && (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE + || TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)) pedwarn ("wrong type argument to %s", ((code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) |