From: Jakub Jelinek Date: Thu, 31 Jul 2008 18:07:20 +0000 (+0200) Subject: re PR c++/36405 (ICE with typeid of member function) X-Git-Tag: releases/gcc-4.4.0~3543 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41b059f3d869b456bec3eee7e3eb0ed5ba0a9300;p=thirdparty%2Fgcc.git re PR c++/36405 (ICE with typeid of member function) PR c++/36405 * rtti.c (get_tinfo_decl_dynamic, get_typeid): Call complete_type_or_else even for UNKNOWN_TYPE to get diagnostics. * g++.dg/rtti/typeid8.C: New test. From-SVN: r138426 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index db536e4d9d30..c865326d0bc1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-07-31 Jakub Jelinek + + PR c++/36405 + * rtti.c (get_tinfo_decl_dynamic, get_typeid): Call + complete_type_or_else even for UNKNOWN_TYPE to get diagnostics. + 2008-07-31 Jason Merrill PR c++/36633 diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index d2e544b0f9e6..e3e5349f5ca9 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -252,7 +252,8 @@ get_tinfo_decl_dynamic (tree exp) /* Peel off cv qualifiers. */ type = TYPE_MAIN_VARIANT (type); - if (CLASS_TYPE_P (type)) + /* For UNKNOWN_TYPEs call complete_type_or_else to get diagnostics. */ + if (CLASS_TYPE_P (type) || TREE_CODE (type) == UNKNOWN_TYPE) type = complete_type_or_else (type, exp); if (!type) @@ -459,7 +460,8 @@ get_typeid (tree type) that is the operand of typeid are always ignored. */ type = TYPE_MAIN_VARIANT (type); - if (CLASS_TYPE_P (type)) + /* For UNKNOWN_TYPEs call complete_type_or_else to get diagnostics. */ + if (CLASS_TYPE_P (type) || TREE_CODE (type) == UNKNOWN_TYPE) type = complete_type_or_else (type, NULL_TREE); if (!type) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f6e855abd083..f05f6276b1f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-07-31 Jakub Jelinek + + PR c++/36405 + * g++.dg/rtti/typeid8.C: New test. + 2008-07-31 Richard Guenther PR tree-optimization/36978 diff --git a/gcc/testsuite/g++.dg/rtti/typeid8.C b/gcc/testsuite/g++.dg/rtti/typeid8.C new file mode 100644 index 000000000000..2b13be5ef526 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid8.C @@ -0,0 +1,26 @@ +// PR c++/36405 +// { dg-do compile } + +#include + +struct A +{ + void foo () + { + typeid (foo).name (); // { dg-error "invalid use of member" } + typeid (A::foo).name (); // { dg-error "invalid use of member" } + } + void bar () + { + typeid (foo).name (); // { dg-error "invalid use of member" } + typeid (A::foo).name (); // { dg-error "invalid use of member" } + } + static void baz () + { + typeid (baz).name (); + typeid (A::baz).name (); + } +}; + +const char *p1 = typeid (A::foo).name (); // { dg-error "invalid use of non-static member" } +const char *p2 = typeid (A::baz).name ();