re PR c++/18652 (ICE on invalid redeclaration)
PR c++/18652 * name-lookup.c (pushtag): Change return type to tree. * cp-tree.h (pushtag): Adjust declaration. * decl.c (xref_tag, start_enum): Use return value of pushtag. * pt.c (push_template_decl_real): Return immediately if pushdecl_namespace_level returns error_mark_node. * g++.dg/lookup/crash6.C: New test. From-SVN: r91470
This commit is contained in:
parent
4f70f9d237
commit
c6f9f83bc8
7 changed files with 36 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-11-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/18652
|
||||
* name-lookup.c (pushtag): Change return type to tree.
|
||||
* cp-tree.h (pushtag): Adjust declaration.
|
||||
* decl.c (xref_tag, start_enum): Use return value of pushtag.
|
||||
* pt.c (push_template_decl_real): Return immediately if
|
||||
pushdecl_namespace_level returns error_mark_node.
|
||||
|
||||
2004-11-27 Kazu Hirata <kazu@cs.umass.edu>
|
||||
|
||||
* pt.c: Fix a comment typo.
|
||||
|
|
|
@ -3707,7 +3707,7 @@ extern void delete_block (tree);
|
|||
extern void add_block_current_level (tree);
|
||||
extern void push_switch (tree);
|
||||
extern void pop_switch (void);
|
||||
extern void pushtag (tree, tree, int);
|
||||
extern tree pushtag (tree, tree, int);
|
||||
extern tree make_anon_name (void);
|
||||
extern int decls_match (tree, tree);
|
||||
extern tree duplicate_decls (tree, tree);
|
||||
|
|
|
@ -9284,7 +9284,7 @@ xref_tag (enum tag_types tag_code, tree name,
|
|||
t = make_aggr_type (code);
|
||||
TYPE_CONTEXT (t) = context;
|
||||
/* pushtag only cares whether SCOPE is zero or not. */
|
||||
pushtag (name, t, scope != ts_current);
|
||||
t = pushtag (name, t, scope != ts_current);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -9539,7 +9539,7 @@ start_enum (tree name)
|
|||
name = make_anon_name ();
|
||||
|
||||
enumtype = make_node (ENUMERAL_TYPE);
|
||||
pushtag (name, enumtype, 0);
|
||||
enumtype = pushtag (name, enumtype, 0);
|
||||
}
|
||||
|
||||
return enumtype;
|
||||
|
|
|
@ -4566,9 +4566,10 @@ maybe_process_template_type_declaration (tree type, int globalize,
|
|||
/* Push a tag name NAME for struct/class/union/enum type TYPE.
|
||||
Normally put it into the inner-most non-sk_cleanup scope,
|
||||
but if GLOBALIZE is true, put it in the inner-most non-class scope.
|
||||
The latter is needed for implicit declarations. */
|
||||
The latter is needed for implicit declarations.
|
||||
Returns TYPE upon success and ERROR_MARK_NODE otherwise. */
|
||||
|
||||
void
|
||||
tree
|
||||
pushtag (tree name, tree type, int globalize)
|
||||
{
|
||||
struct cp_binding_level *b;
|
||||
|
@ -4633,6 +4634,8 @@ pushtag (tree name, tree type, int globalize)
|
|||
|
||||
d = maybe_process_template_type_declaration (type,
|
||||
globalize, b);
|
||||
if (d == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
if (b->kind == sk_class)
|
||||
{
|
||||
|
@ -4695,7 +4698,7 @@ pushtag (tree name, tree type, int globalize)
|
|||
tree d = build_decl (TYPE_DECL, NULL_TREE, type);
|
||||
TYPE_STUB_DECL (type) = pushdecl_with_scope (d, b);
|
||||
}
|
||||
timevar_pop (TV_NAME_LOOKUP);
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, type);
|
||||
}
|
||||
|
||||
/* Subroutines for reverting temporarily to top-level for instantiation
|
||||
|
|
|
@ -3145,7 +3145,11 @@ push_template_decl_real (tree decl, int is_friend)
|
|||
parameters of the class. */
|
||||
if (new_template_p && !ctx
|
||||
&& !(is_friend && template_class_depth (current_class_type) > 0))
|
||||
tmpl = pushdecl_namespace_level (tmpl);
|
||||
{
|
||||
tmpl = pushdecl_namespace_level (tmpl);
|
||||
if (tmpl == error_mark_node)
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
if (primary)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2004-11-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/18652
|
||||
* g++.dg/lookup/crash6.C: New test.
|
||||
|
||||
2004-11-29 Hans-Peter Nilsson <hp@bitrange.com>
|
||||
|
||||
PR middle-end/18164
|
||||
|
|
8
gcc/testsuite/g++.dg/lookup/crash6.C
Normal file
8
gcc/testsuite/g++.dg/lookup/crash6.C
Normal file
|
@ -0,0 +1,8 @@
|
|||
// { dg-do compile }
|
||||
|
||||
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
|
||||
|
||||
// PR c++/18652: ICE redeclaring variable as template.
|
||||
|
||||
int A; // { dg-error "previous declaration" }
|
||||
template<int> struct A; // { dg-error "different kind of symbol" }
|
Loading…
Add table
Reference in a new issue