Commit 4514aa8c by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/19030 (ice on tree check)

cp:
	PR c++/19030
	* cp-tree.h (start_decl): Take pointer to pushed scope, not bool.
	* name-lookup.h (push_scope): Return pushed scope, not flag.
	* name-lookup.c (push_scope): Return scope that should be popped,
	not a flag.
	* decl.c (start_decl): Adjust.
	(grokfndecl): Adjust scope push and pop.
	* decl2.c (check_classfn): Likewise.
	* parser.c (cp_parser_condition, cp_parser_conversion_function_id,
	cp_parser_init_declarator, cp_parser_direct_declarator,
	cp_parser_class_specifier, cp_parser_class_head,
	cp_parser_lookup_name,
	cp_parser_constructor_declarator_p): Likewise.
	* pt.c (instantiate_class_template,
	resolve_typename_type): Likewise.
testsuite:
	PR c++/19030
	* g++.dg/parse/crash22.C: New

From-SVN: r92946
parent c2b43d7a
2005-01-05 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19030
* cp-tree.h (start_decl): Take pointer to pushed scope, not bool.
* name-lookup.h (push_scope): Return pushed scope, not flag.
* name-lookup.c (push_scope): Return scope that should be popped,
not a flag.
* decl.c (start_decl): Adjust.
(grokfndecl): Adjust scope push and pop.
* decl2.c (check_classfn): Likewise.
* parser.c (cp_parser_condition, cp_parser_conversion_function_id,
cp_parser_init_declarator, cp_parser_direct_declarator,
cp_parser_class_specifier, cp_parser_class_head,
cp_parser_lookup_name,
cp_parser_constructor_declarator_p): Likewise.
* pt.c (instantiate_class_template,
resolve_typename_type): Likewise.
2005-01-03 Volker Reichelt <reichelt@igpm.rwth-aaachen.de> 2005-01-03 Volker Reichelt <reichelt@igpm.rwth-aaachen.de>
PR c++/14136 PR c++/14136
......
/* Definitions for C++ parsing and type checking. /* Definitions for C++ parsing and type checking.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GCC. This file is part of GCC.
...@@ -3780,7 +3780,7 @@ extern int init_type_desc (void); ...@@ -3780,7 +3780,7 @@ extern int init_type_desc (void);
extern tree check_tag_decl (cp_decl_specifier_seq *); extern tree check_tag_decl (cp_decl_specifier_seq *);
extern tree shadow_tag (cp_decl_specifier_seq *); extern tree shadow_tag (cp_decl_specifier_seq *);
extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *); extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *);
extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, bool *); extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *);
extern void start_decl_1 (tree); extern void start_decl_1 (tree);
extern void cp_finish_decl (tree, tree, tree, int); extern void cp_finish_decl (tree, tree, tree, int);
extern void finish_decl (tree, tree, tree); extern void finish_decl (tree, tree, tree);
......
/* Process declarations and variables for C++ compiler. /* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004,2005 Free Software Foundation, Inc. 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GCC. This file is part of GCC.
...@@ -3687,13 +3687,13 @@ start_decl (const cp_declarator *declarator, ...@@ -3687,13 +3687,13 @@ start_decl (const cp_declarator *declarator,
int initialized, int initialized,
tree attributes, tree attributes,
tree prefix_attributes, tree prefix_attributes,
bool *pop_scope_p) tree *pushed_scope_p)
{ {
tree decl; tree decl;
tree type, tem; tree type, tem;
tree context; tree context;
*pop_scope_p = false; *pushed_scope_p = NULL_TREE;
/* This should only be done once on the top most decl. */ /* This should only be done once on the top most decl. */
if (have_extern_spec) if (have_extern_spec)
...@@ -3725,11 +3725,13 @@ start_decl (const cp_declarator *declarator, ...@@ -3725,11 +3725,13 @@ start_decl (const cp_declarator *declarator,
context = DECL_CONTEXT (decl); context = DECL_CONTEXT (decl);
if (context) if (context)
*pop_scope_p = push_scope (context); {
*pushed_scope_p = push_scope (context);
/* We are only interested in class contexts, later. */ /* We are only interested in class contexts, later. */
if (context && TREE_CODE (context) == NAMESPACE_DECL) if (TREE_CODE (context) == NAMESPACE_DECL)
context = NULL_TREE; context = NULL_TREE;
}
if (initialized) if (initialized)
/* Is it valid for this decl to have an initializer at all? /* Is it valid for this decl to have an initializer at all?
...@@ -5893,7 +5895,7 @@ grokfndecl (tree ctype, ...@@ -5893,7 +5895,7 @@ grokfndecl (tree ctype,
if (old_decl) if (old_decl)
{ {
tree ok; tree ok;
bool pop_p; tree pushed_scope;
/* Since we've smashed OLD_DECL to its /* Since we've smashed OLD_DECL to its
DECL_TEMPLATE_RESULT, we must do the same to DECL. */ DECL_TEMPLATE_RESULT, we must do the same to DECL. */
...@@ -5902,10 +5904,10 @@ grokfndecl (tree ctype, ...@@ -5902,10 +5904,10 @@ grokfndecl (tree ctype,
/* Attempt to merge the declarations. This can fail, in /* Attempt to merge the declarations. This can fail, in
the case of some invalid specialization declarations. */ the case of some invalid specialization declarations. */
pop_p = push_scope (ctype); pushed_scope = push_scope (ctype);
ok = duplicate_decls (decl, old_decl); ok = duplicate_decls (decl, old_decl);
if (pop_p) if (pushed_scope)
pop_scope (ctype); pop_scope (pushed_scope);
if (!ok) if (!ok)
{ {
error ("no %q#D member function declared in class %qT", error ("no %q#D member function declared in class %qT",
......
/* Process declarations and variables for C++ compiler. /* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com) Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GCC. This file is part of GCC.
...@@ -627,10 +627,10 @@ check_classfn (tree ctype, tree function, tree template_parms) ...@@ -627,10 +627,10 @@ check_classfn (tree ctype, tree function, tree template_parms)
VEC(tree) *methods = CLASSTYPE_METHOD_VEC (ctype); VEC(tree) *methods = CLASSTYPE_METHOD_VEC (ctype);
tree fndecls, fndecl = 0; tree fndecls, fndecl = 0;
bool is_conv_op; bool is_conv_op;
bool pop_p; tree pushed_scope;
const char *format = NULL; const char *format = NULL;
pop_p = push_scope (ctype); pushed_scope = push_scope (ctype);
for (fndecls = VEC_index (tree, methods, ix); for (fndecls = VEC_index (tree, methods, ix);
fndecls; fndecls = OVL_NEXT (fndecls)) fndecls; fndecls = OVL_NEXT (fndecls))
{ {
...@@ -669,8 +669,8 @@ check_classfn (tree ctype, tree function, tree template_parms) ...@@ -669,8 +669,8 @@ check_classfn (tree ctype, tree function, tree template_parms)
== DECL_TI_TEMPLATE (fndecl)))) == DECL_TI_TEMPLATE (fndecl))))
break; break;
} }
if (pop_p) if (pushed_scope)
pop_scope (ctype); pop_scope (pushed_scope);
if (fndecls) if (fndecls)
return OVL_CURRENT (fndecls); return OVL_CURRENT (fndecls);
error ("prototype for %q#D does not match any in class %qT", error ("prototype for %q#D does not match any in class %qT",
......
/* Definitions for C++ name lookup routines. /* Definitions for C++ name lookup routines.
Copyright (C) 2003, 2004 Free Software Foundation, Inc. Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC. This file is part of GCC.
...@@ -2214,16 +2214,14 @@ is_ancestor (tree root, tree child) ...@@ -2214,16 +2214,14 @@ is_ancestor (tree root, tree child)
} }
} }
/* Enter the class or namespace scope indicated by T suitable for /* Enter the class or namespace scope indicated by T suitable for name
name lookup. T can be arbitrary scope, not necessary nested inside lookup. T can be arbitrary scope, not necessary nested inside the
the current scope. Returns TRUE iff pop_scope should be called current scope. Returns a non-null scope to pop iff pop_scope
later to exit this scope. */ should be called later to exit this scope. */
bool tree
push_scope (tree t) push_scope (tree t)
{ {
bool pop = true;
if (TREE_CODE (t) == NAMESPACE_DECL) if (TREE_CODE (t) == NAMESPACE_DECL)
push_decl_namespace (t); push_decl_namespace (t);
else if (CLASS_TYPE_P (t)) else if (CLASS_TYPE_P (t))
...@@ -2236,10 +2234,10 @@ push_scope (tree t) ...@@ -2236,10 +2234,10 @@ push_scope (tree t)
need to re-enter the scope. Since we are not actually need to re-enter the scope. Since we are not actually
pushing a new scope, our caller should not call pushing a new scope, our caller should not call
pop_scope. */ pop_scope. */
pop = false; t = NULL_TREE;
} }
return pop; return t;
} }
/* Leave scope pushed by push_scope. */ /* Leave scope pushed by push_scope. */
......
/* Declarations for C++ name lookup routines. /* Declarations for C++ name lookup routines.
Copyright (C) 2003, 2004 Free Software Foundation, Inc. Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC. This file is part of GCC.
...@@ -299,7 +299,7 @@ extern void pop_from_top_level (void); ...@@ -299,7 +299,7 @@ extern void pop_from_top_level (void);
extern void pop_everything (void); extern void pop_everything (void);
extern void keep_next_level (bool); extern void keep_next_level (bool);
extern bool is_ancestor (tree, tree); extern bool is_ancestor (tree, tree);
extern bool push_scope (tree); extern tree push_scope (tree);
extern void pop_scope (tree); extern void pop_scope (tree);
extern tree push_inner_scope (tree); extern tree push_inner_scope (tree);
extern void pop_inner_scope (tree, tree); extern void pop_inner_scope (tree, tree);
......
/* Handle parameterized types (templates) for GNU C++. /* Handle parameterized types (templates) for GNU C++.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004 Free Software Foundation, Inc. 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
Rewritten by Jason Merrill (jason@cygnus.com). Rewritten by Jason Merrill (jason@cygnus.com).
...@@ -5578,13 +5578,13 @@ instantiate_class_template (tree type) ...@@ -5578,13 +5578,13 @@ instantiate_class_template (tree type)
{ {
tree pbase_binfo; tree pbase_binfo;
tree context = TYPE_CONTEXT (type); tree context = TYPE_CONTEXT (type);
bool pop_p; tree pushed_scope;
int i; int i;
/* We must enter the scope containing the type, as that is where /* We must enter the scope containing the type, as that is where
the accessibility of types named in dependent bases are the accessibility of types named in dependent bases are
looked up from. */ looked up from. */
pop_p = push_scope (context ? context : global_namespace); pushed_scope = push_scope (context ? context : global_namespace);
/* Substitute into each of the bases to determine the actual /* Substitute into each of the bases to determine the actual
basetypes. */ basetypes. */
...@@ -5606,8 +5606,8 @@ instantiate_class_template (tree type) ...@@ -5606,8 +5606,8 @@ instantiate_class_template (tree type)
/* The list is now in reverse order; correct that. */ /* The list is now in reverse order; correct that. */
base_list = nreverse (base_list); base_list = nreverse (base_list);
if (pop_p) if (pushed_scope)
pop_scope (context ? context : global_namespace); pop_scope (pushed_scope);
} }
/* Now call xref_basetypes to set up all the base-class /* Now call xref_basetypes to set up all the base-class
information. */ information. */
...@@ -12286,7 +12286,7 @@ resolve_typename_type (tree type, bool only_current_p) ...@@ -12286,7 +12286,7 @@ resolve_typename_type (tree type, bool only_current_p)
tree name; tree name;
tree decl; tree decl;
int quals; int quals;
bool pop_p; tree pushed_scope;
gcc_assert (TREE_CODE (type) == TYPENAME_TYPE); gcc_assert (TREE_CODE (type) == TYPENAME_TYPE);
...@@ -12315,7 +12315,7 @@ resolve_typename_type (tree type, bool only_current_p) ...@@ -12315,7 +12315,7 @@ resolve_typename_type (tree type, bool only_current_p)
/* Enter the SCOPE so that name lookup will be resolved as if we /* Enter the SCOPE so that name lookup will be resolved as if we
were in the class definition. In particular, SCOPE will no were in the class definition. In particular, SCOPE will no
longer be considered a dependent type. */ longer be considered a dependent type. */
pop_p = push_scope (scope); pushed_scope = push_scope (scope);
/* Look up the declaration. */ /* Look up the declaration. */
decl = lookup_member (scope, name, /*protect=*/0, /*want_type=*/true); decl = lookup_member (scope, name, /*protect=*/0, /*want_type=*/true);
/* Obtain the set of qualifiers applied to the TYPE. */ /* Obtain the set of qualifiers applied to the TYPE. */
...@@ -12345,8 +12345,8 @@ resolve_typename_type (tree type, bool only_current_p) ...@@ -12345,8 +12345,8 @@ resolve_typename_type (tree type, bool only_current_p)
if (type != error_mark_node && quals) if (type != error_mark_node && quals)
type = cp_build_qualified_type (type, quals); type = cp_build_qualified_type (type, quals);
/* Leave the SCOPE. */ /* Leave the SCOPE. */
if (pop_p) if (pushed_scope)
pop_scope (scope); pop_scope (pushed_scope);
return type; return type;
} }
......
2005-01-05 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19030
* g++.dg/parse/crash22.C: New
2005-01-04 Geoffrey Keating <geoffk@apple.com> 2005-01-04 Geoffrey Keating <geoffk@apple.com>
PR 19257 PR 19257
......
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 Jan 2005 <nathan@codesourcery.com>
// PR 19030: ICE
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
struct A;
namespace N
{
struct A;
}
using namespace N;
int A::i; // { dg-error "not been declared|declared here" "" }
int A::i; // { dg-error "not been declared|redefinition of" "" }
namespace N
{
struct C;
struct C {};
}
class D : N::C {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment