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
This commit is contained in:
Nathan Sidwell 2004-12-03 10:51:13 +00:00 committed by Nathan Sidwell
parent bb59c33970
commit f4ed7d2144
4 changed files with 33 additions and 2 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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);

View File

@ -1,5 +1,8 @@
2004-12-03 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18782
* g++.dg/parse/ptrmem2.C: New.
PR c++/18318
* g++.dg/template/new1.C: New.

View File

@ -0,0 +1,11 @@
// { 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" "" }