diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 286a19bc9f51..eb9656f48982 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-05-14 Paolo Carlini + + PR c++/29928 + * rtti.c (get_tinfo_decl_dynamic, get_typeid): Try to complete the + type only if is a class type (5.2.8/4). + 2007-05-14 Rafael Avila de Espindola * cp-objcp-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove. diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 121699f669d7..1891f3b48332 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -238,7 +238,7 @@ get_tinfo_decl_dynamic (tree exp) /* Peel off cv qualifiers. */ type = TYPE_MAIN_VARIANT (type); - if (!VOID_TYPE_P (type)) + if (CLASS_TYPE_P (type)) type = complete_type_or_else (type, exp); if (!type) @@ -431,7 +431,7 @@ get_typeid (tree type) that is the operand of typeid are always ignored. */ type = TYPE_MAIN_VARIANT (type); - if (!VOID_TYPE_P (type)) + if (CLASS_TYPE_P (type)) type = complete_type_or_else (type, NULL_TREE); if (!type) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ddb8c1f348fd..184d6dfbb6ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-05-14 Paolo Carlini + + PR c++/29928 + * g++.dg/rtti/typeid5.C: New. + 2007-05-14 Francois-Xavier Coudert PR fortran/31725 diff --git a/gcc/testsuite/g++.dg/rtti/typeid5.C b/gcc/testsuite/g++.dg/rtti/typeid5.C new file mode 100644 index 000000000000..ef769ce533a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid5.C @@ -0,0 +1,13 @@ +// PR c++/29928 +// { dg-do compile } + +#include + +struct S; + +void f() +{ + const std::type_info& info1 = typeid(int []); + const std::type_info& info2 = typeid(S [3]); + const std::type_info& info3 = typeid(S []); +}