Darwin : Avoid a C++ ODR violation seen with LTO.
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 22 Nov 2020 11:19:32 +0000 (11:19 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Sun, 22 Nov 2020 12:56:20 +0000 (12:56 +0000)
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.

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

index 9034f49908e040950fe8835f985b19d1dd152fcb..961723057117193b1d5503d6f3bb9de9363a4ca2 100644 (file)
@@ -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;