+2007-11-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/32260
+ * rtti.c (enum_tinfo_kind): Fix TK_TYPE_INFO_TYPE comment.
+ (typeid_ok_p): Use the same alias set for abi::__type_info_pseudo
+ as for std::type_info.
+
2007-10-31 Paolo Carlini <pcarlini@suse.de>
PR c++/33494
typedef enum tinfo_kind
{
- TK_TYPE_INFO_TYPE, /* std::type_info */
+ TK_TYPE_INFO_TYPE, /* abi::__type_info_pseudo */
TK_BASE_TYPE, /* abi::__base_class_type_info */
TK_BUILTIN_TYPE, /* abi::__fundamental_type_info */
TK_ARRAY_TYPE, /* abi::__array_type_info */
static bool
typeid_ok_p (void)
{
+ tree pseudo_type_info, type_info_type;
+
if (! flag_rtti)
{
error ("cannot use typeid with -fno-rtti");
return false;
}
+ pseudo_type_info
+ = VEC_index (tinfo_s, tinfo_descs, TK_TYPE_INFO_TYPE)->type;
+ type_info_type = TYPE_MAIN_VARIANT (const_type_info_type_node);
+
+ /* Make sure abi::__type_info_pseudo has the same alias set
+ as std::type_info. */
+ if (! TYPE_ALIAS_SET_KNOWN_P (pseudo_type_info))
+ TYPE_ALIAS_SET (pseudo_type_info) = get_alias_set (type_info_type);
+ else
+ gcc_assert (TYPE_ALIAS_SET (pseudo_type_info)
+ == get_alias_set (type_info_type));
+
return true;
}
--- /dev/null
+// PR c++/32260
+// { dg-do compile }
+// { dg-options "-O2 -W -Wall" }
+
+#include <typeinfo>
+
+const std::type_info &
+f1 (int i)
+{
+ return typeid (i + 1);
+}
+
+const std::type_info &
+f2 ()
+{
+ return typeid (int);
+}
+
+struct A
+{
+ A ();
+ virtual ~A ();
+ void foo ();
+};
+
+const std::type_info &
+f3 ()
+{
+ return typeid (A);
+}
+
+const std::type_info &
+f4 (A *p)
+{
+ return typeid (*p);
+}
+
+const std::type_info &
+f5 ()
+{
+ return typeid (int *);
+}
+
+const std::type_info &
+f6 ()
+{
+ return typeid (int [26][12]);
+}
+
+const std::type_info &
+f7 ()
+{
+ return typeid (int [26][12]);
+}
+
+void (A::*pmr) ();
+const std::type_info &
+f8 ()
+{
+ return typeid (pmr);
+}