public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7594] Fix ICE on atomic enumeration type with LTO
@ 2021-03-10 11:32 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-03-10 11:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1c3c12b0a6fdffce0eca0b21518cbb53b20abff1

commit r11-7594-g1c3c12b0a6fdffce0eca0b21518cbb53b20abff1
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Mar 10 12:04:25 2021 +0100

    Fix ICE on atomic enumeration type with LTO
    
    This is a strange regression whereby an enumeration type declared as
    atomic (or volatile) incorrectly triggers the ODR machinery for its
    values in LTO mode.
    
    gcc/ada/
            * gcc-interface/decl.c (gnat_to_gnu_entity): Build a TYPE_STUB_DECL
            for the main variant of an enumeration type declared as volatile.
    gcc/testsuite/
            * gnat.dg/specs/lto25.ads: New test.

Diff:
---
 gcc/ada/gcc-interface/decl.c          |  4 ++++
 gcc/testsuite/gnat.dg/specs/lto25.ads | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index aea191c7ecb..27ef51a9eed 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -4713,6 +4713,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	  const int quals
 	    = TYPE_QUAL_VOLATILE
 	      | (Is_Full_Access (gnat_entity) ? TYPE_QUAL_ATOMIC : 0);
+	  /* This is required by free_lang_data_in_type to disable the ODR.  */
+	  if (TREE_CODE (gnu_type) == ENUMERAL_TYPE)
+	    TYPE_STUB_DECL (gnu_type)
+	      = create_type_stub_decl (TYPE_NAME (gnu_type), gnu_type);
 	  gnu_type = change_qualified_type (gnu_type, quals);
 	}
 
diff --git a/gcc/testsuite/gnat.dg/specs/lto25.ads b/gcc/testsuite/gnat.dg/specs/lto25.ads
new file mode 100644
index 00000000000..89876b64a00
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/lto25.ads
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+-- { dg-options "-flto" { target lto } }
+
+package Lto25 is
+
+  type Enum is (One, Two, Three) with Atomic;
+
+  type Rec is record
+    E : Enum := One;
+  end record;
+
+end Lto25;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-10 11:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 11:32 [gcc r11-7594] Fix ICE on atomic enumeration type with LTO Eric Botcazou

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).