* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138426
138bc75d-0d04-0410-961f-
82ee72b054a4
+2008-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ 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 <jason@redhat.com>
PR c++/36633
/* 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)
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)
+2008-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/36405
+ * g++.dg/rtti/typeid8.C: New test.
+
2008-07-31 Richard Guenther <rguenther@suse.de>
PR tree-optimization/36978
--- /dev/null
+// PR c++/36405
+// { dg-do compile }
+
+#include <typeinfo>
+
+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 ();