From: Richard Stallman Date: Tue, 2 Mar 1993 03:07:56 +0000 (+0000) Subject: (build_unary_op): Warn if increment `struct unknown *'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6bc4e3d04fe7c451bc0ded9f60ef70f96a732ebf;p=gcc.git (build_unary_op): Warn if increment `struct unknown *'. From-SVN: r3585 --- diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 68c6679cd80..6f200484280 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)