aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin v. Löwis <loewis@informatik.hu-berlin.de>1998-10-22 14:52:02 +0000
committerMartin v. Löwis <loewis@gcc.gnu.org>1998-10-22 14:52:02 +0000
commitf09bbbedfb1ad34a0277b9866ecb33a0ad198730 (patch)
tree33a57098839059f547c9ca6f2bb7167cc36c0804
parente0afe616d4883f8dcfdafda44373d3f8190b9e20 (diff)
downloadgcc-f09bbbedfb1ad34a0277b9866ecb33a0ad198730.zip
gcc-f09bbbedfb1ad34a0277b9866ecb33a0ad198730.tar.gz
gcc-f09bbbedfb1ad34a0277b9866ecb33a0ad198730.tar.bz2
parse.y (named_class_head): Push into class while parsing the base class list.
* parse.y (named_class_head): Push into class while parsing the base class list. * decl2.c (push_scope, pop_scope): New functions. * tree.h: Declare them. From-SVN: r23224
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl2.c24
-rw-r--r--gcc/cp/parse.y11
4 files changed, 39 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f2be60c..e614e72 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
-1998-10-22 Martin v. Löwis <loewis@informatik.hu-berlin.de>
+1998-10-22 Martin von Löwis <loewis@informatik.hu-berlin.de>
+ * parse.y (named_class_head): Push into class while parsing the
+ base class list.
+ * decl2.c (push_scope, pop_scope): New functions.
+ * cp-tree.h: Declare them.
* init.c (build_new_1): Delay cleanup until end of full expression.
1998-10-21 Jason Merrill <jason@yorick.cygnus.com>
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d499327..51c531b 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2668,6 +2668,8 @@ extern void set_decl_namespace PROTO((tree, tree));
extern tree current_decl_namespace PROTO((void));
extern void push_decl_namespace PROTO((tree));
extern void pop_decl_namespace PROTO((void));
+extern void push_scope PROTO((tree));
+extern void pop_scope PROTO((tree));
extern void do_namespace_alias PROTO((tree, tree));
extern void do_toplevel_using_decl PROTO((tree));
extern void do_local_using_decl PROTO((tree));
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index f0b3167..302138a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4332,6 +4332,30 @@ check_decl_namespace ()
my_friendly_assert (decl_namespace_list == NULL_TREE, 980711);
}
+/* Enter a class or namespace scope. */
+
+void
+push_scope (t)
+ tree t;
+{
+ if (TREE_CODE (t) == NAMESPACE_DECL)
+ push_decl_namespace (t);
+ else
+ pushclass (t, 2);
+}
+
+/* Leave scope pushed by push_scope. */
+
+void
+pop_scope (t)
+ tree t;
+{
+ if (TREE_CODE (t) == NAMESPACE_DECL)
+ pop_decl_namespace ();
+ else
+ popclass (1);
+}
+
/* [basic.lookup.koenig] */
/* A non-zero return value in the functions below indicates an error.
All nodes allocated in the procedure are on the scratch obstack. */
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index d654f5a..2aba4a5 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -2235,14 +2235,19 @@ named_class_head:
{ $$ = xref_tag (current_aggr, $1, 1); }
| named_class_head_sans_basetype_defn
{ $<ttype>$ = xref_tag (current_aggr, $1, 0); }
+ /* Class name is unqualified, so we look for base classes
+ in the current scope. */
maybe_base_class_list %prec EMPTY
{
$$ = $<ttype>2;
if ($3)
xref_basetypes (current_aggr, $1, $<ttype>2, $3);
}
- | named_complex_class_head_sans_basetype maybe_base_class_list
+ | named_complex_class_head_sans_basetype
+ { push_scope (CP_DECL_CONTEXT ($1)); }
+ maybe_base_class_list
{
+ pop_scope (CP_DECL_CONTEXT ($1));
$$ = TREE_TYPE ($1);
if (TREE_INT_CST_LOW (current_aggr) == union_type
&& TREE_CODE ($$) != UNION_TYPE)
@@ -2250,10 +2255,10 @@ named_class_head:
else if (TREE_CODE ($$) == UNION_TYPE
&& TREE_INT_CST_LOW (current_aggr) != union_type)
cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
- if ($2)
+ if ($3)
{
maybe_process_partial_specialization ($$);
- xref_basetypes (current_aggr, $1, $$, $2);
+ xref_basetypes (current_aggr, $1, $$, $3);
}
}
;