re PR c++/32260 (too many warning: dereferencing type-punned pointer will break strict-aliasing rules)

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.

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

From-SVN: r129835
This commit is contained in:
Jakub Jelinek 2007-11-01 23:50:32 +01:00 committed by Jakub Jelinek
parent 945bfaca2e
commit 3a44f39543
4 changed files with 88 additions and 1 deletions

View File

@ -1,3 +1,10 @@
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

View File

@ -79,7 +79,7 @@ DEF_VEC_ALLOC_O(tinfo_s,gc);
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 */
@ -264,6 +264,8 @@ get_tinfo_decl_dynamic (tree exp)
static bool
typeid_ok_p (void)
{
tree pseudo_type_info, type_info_type;
if (! flag_rtti)
{
error ("cannot use typeid with -fno-rtti");
@ -276,6 +278,18 @@ typeid_ok_p (void)
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;
}

View File

@ -1,3 +1,8 @@
2007-11-01 Jakub Jelinek <jakub@redhat.com>
PR c++/32260
* g++.dg/rtti/typeid7.C: New test.
2007-11-01 Tom Tromey <tromey@redhat.com>
PR preprocessor/30805:

View File

@ -0,0 +1,61 @@
// 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);
}