Commit 6bc4e3d0 by Richard Stallman

(build_unary_op): Warn if increment `struct unknown *'.

From-SVN: r3585
parent 42981920
...@@ -3014,9 +3014,16 @@ build_unary_op (code, xarg, noconvert) ...@@ -3014,9 +3014,16 @@ build_unary_op (code, xarg, noconvert)
if (typecode == POINTER_TYPE) if (typecode == POINTER_TYPE)
{ {
if ((pedantic || warn_pointer_arith) /* If pointer target is an undefined struct,
&& (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE we just cannot know how to do the arithmetic. */
|| TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)) 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", pedwarn ("wrong type argument to %s",
((code == PREINCREMENT_EXPR ((code == PREINCREMENT_EXPR
|| code == POSTINCREMENT_EXPR) || code == POSTINCREMENT_EXPR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment