+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.
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);
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
name = make_anon_name ();
enumtype = make_node (ENUMERAL_TYPE);
- pushtag (name, enumtype, 0);
+ enumtype = pushtag (name, enumtype, 0);
}
return enumtype;
/* 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;
d = maybe_process_template_type_declaration (type,
globalize, b);
+ if (d == error_mark_node)
+ return error_mark_node;
if (b->kind == sk_class)
{
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);
}
\f
/* Subroutines for reverting temporarily to top-level for instantiation
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)
{
+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
--- /dev/null
+// { 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" }