* [pushed] Darwin : Avoid a C++ ODR violation seen with LTO.
@ 2020-11-22 14:49 Iain Sandoe
0 siblings, 0 replies; only message in thread
From: Iain Sandoe @ 2020-11-22 14:49 UTC (permalink / raw)
To: GCC Patches
Hi
We have a similar code pattern in darwin-c.c to one in c-pragmas
(most likely a cut & paste) with a struct type used locally to the
TU. With C++ we need to rename the type to avoid an ODR violation.
tested on x86_64-darwin19 ‘—with-build-config=bootstrap-lto-noplugin’
pushed to master,
thanks
Iain
gcc/ChangeLog:
* config/darwin-c.c (struct f_align_stack): Rename
to type from align_stack to f_align_stack.
(push_field_alignment): Likewise.
(pop_field_alignment): Likewise.
---
gcc/config/darwin-c.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c
index 9034f49908e..96172305711 100644
--- a/gcc/config/darwin-c.c
+++ b/gcc/config/darwin-c.c
@@ -44,13 +44,12 @@ static bool using_frameworks = false;
static const char *find_subframework_header (cpp_reader *pfile, const char *header,
cpp_dir **dirp);
-typedef struct align_stack
-{
- int alignment;
- struct align_stack * prev;
-} align_stack;
+struct fld_align_stack {
+ int alignment;
+ struct fld_align_stack * prev;
+};
-static struct align_stack * field_align_stack = NULL;
+static struct fld_align_stack * field_align_stack;
/* Maintain a small stack of alignments. This is similar to pragma
pack's stack, but simpler. */
@@ -58,7 +57,7 @@ static struct align_stack * field_align_stack = NULL;
static void
push_field_alignment (int bit_alignment)
{
- align_stack *entry = XNEW (align_stack);
+ fld_align_stack *entry = XNEW (fld_align_stack);
entry->alignment = maximum_field_alignment;
entry->prev = field_align_stack;
@@ -72,7 +71,7 @@ pop_field_alignment (void)
{
if (field_align_stack)
{
- align_stack *entry = field_align_stack;
+ fld_align_stack *entry = field_align_stack;
maximum_field_alignment = entry->alignment;
field_align_stack = entry->prev;
--
2.24.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-22 14:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 14:49 [pushed] Darwin : Avoid a C++ ODR violation seen with LTO Iain Sandoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).