re PR c++/87547 (G++ reports bad type names for bit-field members)
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Oct 2018 07:07:22 +0000 (09:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Oct 2018 07:07:22 +0000 (09:07 +0200)
PR c++/87547
* rtti.c (get_tinfo_decl_dynamic): Use unlowered_expr_type instead
of TREE_TYPE.

* g++.dg/rtti/typeid12.C: New test.

From-SVN: r265033

gcc/cp/ChangeLog
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/rtti/typeid12.C [new file with mode: 0644]

index af8cb764139e7150cf3550cd68f85ca92afc347c..0ac28f934d9864ef96b9ef5dcb38445c9ca89bdc 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87547
+       * rtti.c (get_tinfo_decl_dynamic): Use unlowered_expr_type instead
+       of TREE_TYPE.
+
 2018-10-10  Marek Polacek  <polacek@redhat.com>
 
        PR c++/87567 - constexpr rejects call to non-constexpr function.
index 94a921987815b30bb6e6c8e6108c5e93f2907582..a0629e193604c980962c0809c6390033cf06b700 100644 (file)
@@ -273,7 +273,7 @@ get_tinfo_decl_dynamic (tree exp, tsubst_flags_t complain)
   exp = resolve_nondeduced_context (exp, complain);
 
   /* peel back references, so they match.  */
-  type = non_reference (TREE_TYPE (exp));
+  type = non_reference (unlowered_expr_type (exp));
 
   /* Peel off cv qualifiers.  */
   type = TYPE_MAIN_VARIANT (type);
index 05dab1f46a7a5e548485642a962cdf2d6635fe13..f0eabfcbe930f235035fed87ed963a9fdcc60b39 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87547
+       * g++.dg/rtti/typeid12.C: New test.
+
 2018-10-10  Eric Botcazou  <ebotcazou@adacore.com>
 
        * g++.dg/other/pr87574.C: New test.
diff --git a/gcc/testsuite/g++.dg/rtti/typeid12.C b/gcc/testsuite/g++.dg/rtti/typeid12.C
new file mode 100644 (file)
index 0000000..a64d9c3
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/87547
+// { dg-do run }
+
+#include <typeinfo>
+
+struct S { unsigned int a : 4; unsigned int b : 12; int c; unsigned long d : 8; } s;
+
+int
+main ()
+{
+  if (typeid (s.a) != typeid (unsigned int)
+      || typeid (s.b) != typeid (unsigned int)
+      || typeid (s.c) != typeid (int)
+      || typeid (s.d) != typeid (unsigned long))
+    __builtin_abort ();
+}