+2004-12-03 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/18782
+ * decl.c (grokdeclarator): Make sure class in pointer to member is
+ not a namespace.
+
2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18318
else if (TREE_CODE (type) == METHOD_TYPE)
type = build_ptrmemfunc_type (build_pointer_type (type));
else if (declarator->kind == cdk_ptrmem)
- type = build_ptrmem_type (declarator->u.pointer.class_type,
- type);
+ {
+ /* We might have parsed a namespace as the class type. */
+ if (TREE_CODE (declarator->u.pointer.class_type)
+ == NAMESPACE_DECL)
+ {
+ error ("%qD is a namespace",
+ declarator->u.pointer.class_type);
+ type = build_pointer_type (type);
+ }
+ else
+ type = build_ptrmem_type (declarator->u.pointer.class_type,
+ type);
+ }
else
type = build_pointer_type (type);
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 2 Dec 2004 <nathan@codesourcery.com>
+
+// PR 18782: ICE with ptr-to-member
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+
+namespace A {}
+
+int A::* p; // { dg-error "is a namespace" "" }