Only warn about a superfluous "packed" attribute for a struct, if it was actually...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 30 Nov 2008 14:28:44 +0000 (14:28 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sun, 30 Nov 2008 14:28:44 +0000 (14:28 +0000)
[r24161]

parser.c

index b381548..e0a0716 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3557,12 +3557,15 @@ static void finish_struct_type(compound_type_t *type)
        if (offset > size)
                need_pad = true;
 
-       if (warning.padded && need_pad) {
-               warningf(&compound->base.source_position, "'%T' needs padding", type);
-       }
-       if (warning.packed && !need_pad) {
-               warningf(&compound->base.source_position,
-                               "superfluous packed attribute on '%T'", type);
+       if (need_pad) {
+               if (warning.padded) {
+                       warningf(&compound->base.source_position, "'%T' needs padding", type);
+               }
+       } else {
+               if (compound->modifiers & DM_PACKED && warning.packed) {
+                       warningf(&compound->base.source_position,
+                                       "superfluous packed attribute on '%T'", type);
+               }
        }
 
        type->base.size      = offset;