static int
classify_argument (machine_mode mode, const_tree type,
- enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
+ enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset,
+ int &zero_width_bitfields)
{
HOST_WIDE_INT bytes
= mode == BLKmode ? int_size_in_bytes (type) : (int) GET_MODE_SIZE (mode);
misaligned integers. */
if (DECL_BIT_FIELD (field))
{
+ if (integer_zerop (DECL_SIZE (field)))
+ {
+ if (DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (field))
+ continue;
+ if (zero_width_bitfields != 2)
+ {
+ zero_width_bitfields = 1;
+ continue;
+ }
+ }
for (i = (int_bit_position (field)
+ (bit_offset % 64)) / 8 / 8;
i < ((int_bit_position (field) + (bit_offset % 64))
num = classify_argument (TYPE_MODE (type), type,
subclasses,
(int_bit_position (field)
- + bit_offset) % 512);
+ + bit_offset) % 512,
+ zero_width_bitfields);
if (!num)
return 0;
pos = (int_bit_position (field)
{
int num;
num = classify_argument (TYPE_MODE (TREE_TYPE (type)),
- TREE_TYPE (type), subclasses, bit_offset);
+ TREE_TYPE (type), subclasses, bit_offset,
+ zero_width_bitfields);
if (!num)
return 0;
num = classify_argument (TYPE_MODE (TREE_TYPE (field)),
TREE_TYPE (field), subclasses,
- bit_offset);
+ bit_offset, zero_width_bitfields);
if (!num)
return 0;
for (i = 0; i < num && i < words; i++)
X86_64_SSEUP_CLASS, everything should be passed in
memory. */
if (classes[0] != X86_64_SSE_CLASS)
- return 0;
+ return 0;
for (i = 1; i < words; i++)
if (classes[i] != X86_64_SSEUP_CLASS)
classes[i] = X86_64_SSE_CLASS;
}
- /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
- everything should be passed in memory. */
+ /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
+ everything should be passed in memory. */
if (classes[i] == X86_64_X87UP_CLASS
&& (classes[i - 1] != X86_64_X87_CLASS))
{
}
}
+/* Wrapper around classify_argument with the extra zero_width_bitfields
+ argument, to diagnose GCC 12.1 ABI differences for C. */
+
+static int
+classify_argument (machine_mode mode, const_tree type,
+ enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
+{
+ int zero_width_bitfields = 0;
+ static bool warned = false;
+ int n = classify_argument (mode, type, classes, bit_offset,
+ zero_width_bitfields);
+ if (!zero_width_bitfields || warned || !warn_psabi)
+ return n;
+ enum x86_64_reg_class alt_classes[MAX_CLASSES];
+ zero_width_bitfields = 2;
+ if (classify_argument (mode, type, alt_classes, bit_offset,
+ zero_width_bitfields) != n)
+ zero_width_bitfields = 3;
+ else
+ for (int i = 0; i < n; i++)
+ if (classes[i] != alt_classes[i])
+ {
+ zero_width_bitfields = 3;
+ break;
+ }
+ if (zero_width_bitfields == 3)
+ {
+ warned = true;
+ const char *url
+ = CHANGES_ROOT_URL "gcc-12/changes.html#zero_width_bitfields";
+
+ inform (input_location,
+ "the ABI of passing C structures with zero-width bit-fields"
+ " has changed in GCC %{12.1%}", url);
+ }
+ return n;
+}
+
/* Examine the argument and return set number of register required in each
class. Return true iff parameter should be passed in memory. */