mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
Force a large alignment of a variant structure.
This is a temporary band-aid until Bison gets proper alignment handling. We need it on ARM. * data/lalr1.cc (variant): Declare the buffer as a union to force the same alignment as "long double".
This commit is contained in:
committed by
Akim Demaille
parent
0ea583d250
commit
253192e69a
@@ -433,7 +433,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
{]b4_assert_if([
|
{]b4_assert_if([
|
||||||
assert(!built);
|
assert(!built);
|
||||||
built = true;])[
|
built = true;])[
|
||||||
return *new (buffer) T;
|
return *new (buffer.raw) T;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instantiate a \a T in here from \a t.
|
/// Instantiate a \a T in here from \a t.
|
||||||
@@ -443,7 +443,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
{]b4_assert_if([
|
{]b4_assert_if([
|
||||||
assert(!built);
|
assert(!built);
|
||||||
built = true;])[
|
built = true;])[
|
||||||
return *new (buffer) T(t);
|
return *new (buffer.raw) T(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct and fill.
|
/// Construct and fill.
|
||||||
@@ -452,7 +452,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
variant (const T& t)]b4_assert_if([
|
variant (const T& t)]b4_assert_if([
|
||||||
: built(true)])[
|
: built(true)])[
|
||||||
{
|
{
|
||||||
new (buffer) T(t);
|
new (buffer.raw) T(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accessor to a built \a T.
|
/// Accessor to a built \a T.
|
||||||
@@ -461,7 +461,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
as()
|
as()
|
||||||
{]b4_assert_if([
|
{]b4_assert_if([
|
||||||
assert(built);])[
|
assert(built);])[
|
||||||
return reinterpret_cast<T&>(buffer);
|
return reinterpret_cast<T&>(buffer.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Const accessor to a built \a T (for %printer).
|
/// Const accessor to a built \a T (for %printer).
|
||||||
@@ -470,7 +470,7 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
as() const
|
as() const
|
||||||
{]b4_assert_if([
|
{]b4_assert_if([
|
||||||
assert(built);])[
|
assert(built);])[
|
||||||
return reinterpret_cast<const T&>(buffer);
|
return reinterpret_cast<const T&>(buffer.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Swap the content with \a other.
|
/// Swap the content with \a other.
|
||||||
@@ -502,7 +502,12 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A buffer large enough to store any of the semantic values.
|
/// A buffer large enough to store any of the semantic values.
|
||||||
char buffer[S];
|
/// Long double is chosen as it has the strongest alignment
|
||||||
|
/// constraints.
|
||||||
|
union {
|
||||||
|
long double align_me;
|
||||||
|
char raw[S];
|
||||||
|
} buffer;
|
||||||
};
|
};
|
||||||
]])[
|
]])[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
|||||||
Reference in New Issue
Block a user