(build_unary_op): Warn if increment `struct unknown *'.
authorRichard Stallman <rms@gnu.org>
Tue, 2 Mar 1993 03:07:56 +0000 (03:07 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 2 Mar 1993 03:07:56 +0000 (03:07 +0000)
From-SVN: r3585

gcc/c-typeck.c

index 68c6679cd80763f11a3610e43c09678dcac9f474..6f2004842803e15b296b2cca97899a549fcf4435 100644 (file)
@@ -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)