parser: Remove the unused attribute alignment from struct declaration_specifiers_t.
[cparser] / type.c
diff --git a/type.c b/type.c
index 5a71c31..319a9fe 100644 (file)
--- a/type.c
+++ b/type.c
@@ -5,8 +5,8 @@
 #include <config.h>
 
 #include <stdio.h>
-#include <assert.h>
 
+#include "adt/bitfiddle.h"
 #include "type_t.h"
 #include "types.h"
 #include "entity_t.h"
@@ -179,11 +179,6 @@ atomic_type_properties_t pointer_properties = {
        .flags     = ATOMIC_TYPE_FLAG_NONE,
 };
 
-static inline bool is_po2(unsigned x)
-{
-       return (x & (x-1)) == 0;
-}
-
 void init_types(unsigned machine_size)
 {
        obstack_init(&type_obst);
@@ -1463,8 +1458,7 @@ void layout_struct_type(compound_type_t *type)
                        alignment = m_alignment;
 
                if (!compound->packed) {
-                       il_size_t new_offset = (offset + m_alignment-1) & -m_alignment;
-
+                       il_size_t const new_offset = round_up2(offset, m_alignment);
                        if (new_offset > offset) {
                                need_pad = true;
                                offset   = new_offset;
@@ -1479,7 +1473,7 @@ next:
        }
 
        if (!compound->packed) {
-               il_size_t new_offset = (offset + alignment-1) & -alignment;
+               il_size_t const new_offset = round_up2(offset, alignment);
                if (new_offset > offset) {
                        need_pad = true;
                        offset   = new_offset;
@@ -1528,7 +1522,7 @@ void layout_union_type(compound_type_t *type)
                if (m_alignment > alignment)
                        alignment = m_alignment;
        }
-       size = (size + alignment - 1) & -alignment;
+       size = round_up2(size, alignment);
 
        compound->size      = size;
        compound->alignment = alignment;