]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: ICE with bad definition of decimal32 [PR100261]
authorJason Merrill <jason@redhat.com>
Tue, 18 May 2021 21:15:42 +0000 (17:15 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 19 May 2021 00:56:11 +0000 (20:56 -0400)
The change to only look at the global binding for non-classes meant that
here, when dealing with decimal32 which is magically mangled like its first
non-static data member, we got a collision with the mangling for float.
Fixed by also looking up an existing binding for such magical classes.

PR c++/100261

gcc/cp/ChangeLog:

* rtti.c (get_tinfo_decl_direct): Check TYPE_TRANSPARENT_AGGR.

gcc/testsuite/ChangeLog:

* g++.dg/dfp/mangle-6.C: New test.

gcc/cp/rtti.c
gcc/testsuite/g++.dg/dfp/mangle-6.C [new file with mode: 0644]

index 5a33b83afd0c85a04833713abbbce82c3039ea4f..82eaa286514da0c0c072b287f894d558b1f47d8a 100644 (file)
@@ -433,7 +433,7 @@ get_tinfo_decl_direct (tree type, tree name, int pseudo_ix)
   if (!name)
     name = mangle_typeinfo_for_type (type);
 
-  if (!CLASS_TYPE_P (type))
+  if (!CLASS_TYPE_P (type) || TYPE_TRANSPARENT_AGGR (type))
     d = get_global_binding (name);
 
   if (!d)
diff --git a/gcc/testsuite/g++.dg/dfp/mangle-6.C b/gcc/testsuite/g++.dg/dfp/mangle-6.C
new file mode 100644 (file)
index 0000000..9cfb2a9
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/100261
+// { dg-do compile }
+
+#include <typeinfo>
+
+namespace std {
+  namespace decimal {
+    class decimal32 {
+      float private__decfloat32;
+    };
+  }
+}
+
+void
+foo ()
+{
+  typeid (float);
+  typeid (std::decimal::decimal32);
+}