aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-12-03 10:51:13 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-12-03 10:51:13 +0000
commitf4ed7d2144f6a1754e88e03a6529aa79b4da40e4 (patch)
tree8393d870c2f014b0d593734c85999400125c58b4 /gcc/cp/decl.c
parentbb59c339707b521bc956f4ccf08f65fd9fed2fd2 (diff)
downloadgcc-f4ed7d2144f6a1754e88e03a6529aa79b4da40e4.zip
gcc-f4ed7d2144f6a1754e88e03a6529aa79b4da40e4.tar.gz
gcc-f4ed7d2144f6a1754e88e03a6529aa79b4da40e4.tar.bz2
re PR c++/18782 (ICE on invalid pointer-to-member declaration)
cp: PR c++/18782 * decl.c (grokdeclarator): Make sure class in pointer to member is not a namespace. testsuite: PR c++/18782 * g++.dg/parse/ptrmem2.C: New. From-SVN: r91681
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 92f294f..bf7b80f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7430,8 +7430,19 @@ grokdeclarator (const cp_declarator *declarator,
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);